Elements of an IEnumerable sequence do not know about the other elements. I often need to compare an element with a previous or next element. Sometimes I need other context like all the other elements, the previous elements or if an element is the last element. That is why I use an extension method that adds context to all elements.
I saw many password generators but none of them did what I needed. Also it was often not random enough and/or unnesessary complex. So I created my own password generator. It has parameters for the lenght of the password, the minimum lowercase, uppercase, numbers and special characters.
Paging with Linq (to objects) seems quite simple: This is handy when you need a page 'in the middle only' but if you need to enumerate all pages, you have to caculate the number of pages yourself. The next method will help you to get all pages:
Creating of unit tests of a method with 1 bool parameter needs at least 2 unit tests (false and true). But how many unit tests do you need for a parameter of type IEnumerable
While designing a new programming language, I wondered if I would cache query results by default or not. Caching has advantages and disadvantages. I Found a solution that has the best of both worlds. The solution is also possible in C#!
Immaging that you have a customer that should pay you €10, €10, €20, €30, €30. He already paid you €10, €20. You need to know what he still needs to pay you. How will C#/LINQ helps you to give the answer?
Today I saw a Stackoverflow-post about a genaral solution for tree and nodes. It reminds me of a solution I created to store departments in tree. I was surprised that no standard .NET collection does exactly what I need, so I created my own Node
In a project I had to map a lot of external codes and values to our codes and values. This results in methods with switch statements:
In a collection we can easily check if there is any (particular) item: This is a very efficient way to check because it doesn't enumerate the whole collection. After enumerating the first element, the Any() method returns the result. This saves time if the collection is large or enumeration goes slow.
Het is vandaag 5-10-2024, dus is Alex 55 jaren, 6 maanden en 1 week oud.