In C# we use the iterator pattern to iterate over collections like Dictionary, Queue, ArrayList, List and so on. This collections all implement the IEnumerable interface. For many cases this is a much more convenient way to group objects then using regular arrays. Continue reading “C# features – yield return”
Category: FeatureShowcase
C# features: null coalesce & conditional operator
In C# we have nullable types and references which can be null. When we access them in a null state, a NullReferenceException is flying towards us.
There are cases, when the null object pattern may reduce null checks, but there still remain many places in your code where you have to implement them.
Let’s have a look at two C# features for null checking. Continue reading “C# features: null coalesce & conditional operator”
C# features: auto-implemented properties
Properties in C# are used to hide implementation details to the outside. Fields (variables) should normally not be exposed (public).
It’s recommended to use properties instead, wich have get and set “accessors”. From the outside the properties are accessed like fields, but the compiler generates hidden methods.