-
Book Overview & Buying
-
Table Of Contents
.NET 4.0 Generics Beginner's Guide
By :
LINQ Standard Query Operators: FirstOrDefault(), LastOrDefault(), or any operator that ends with "Default" in its name throws a useless null, as the default value, for user-defined objects.
Now, if you have several situations where you have to deal with such values, you would prefer to be able to set a default value of your choice to these collections.
Power Collections offer an algorithm called Fill and a range version called FillRange, which offer functionality to fill a collection or an array with a given default value.
I thought it would be really useful if we can use these two algorithms to brew some default value initialization framework using the LINQ extension method style. Suppose we have a List<string> with 10 entries and we want to set the first four to # and that's needed for our application. In such situations, we can use the framework that we are about to build.
Change the font size
Change margin width
Change background colour