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”
Tag: 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.
C# features: async/await – asynchronous programming
Since today must systems have multiple processor or cores, slow or blocking applications are less accepted than ever.
On the other hand applications have to handle multiple slow interfaces (network, filesystem, database, http, …), which don’t respond as fast as we would like to.
Over the years this became a challenge in development, working with multiple threads and the GUI in parallel isn’t that easy.
Since C# 5 the async and await keywords are available, which abstract this complex problem.
You call a method which has the async keyword in it’s definition. The call returns immediately, you can alter the GUI or do other stuff in parallel. At the point when you finally need the results, you use the await keyword.
Continue reading “C# features: async/await – asynchronous programming”