A2Z.Net : A – Anonymous Types

This article marks the beginning of a new series of posts, which aims to dig deeper into 26 different features of .Net. For the first article, or the A - I have selected Anonymous Types. I would have chosen asynchronous programming, but I have whole dedicated series on asynchronous programming which could followed in this link. Introduced … Continue reading A2Z.Net : A – Anonymous Types

Advertisement

C# 8 : Nullable Reference Types, Null Forgiving and Null Coalescing Assignment

There are some properties that ought to be learned together to understand the complete picture. In this blog post, we will address two of such features. Nullable Reference Types Let us begin by writing some code. public class Foo { public Bar Bar { get; set; } } public class Bar { public int Id … Continue reading C# 8 : Nullable Reference Types, Null Forgiving and Null Coalescing Assignment

Asynchronous Code – Behind the Scenes – 004

During this series of deep dive into the asynchronous calls, we have so far looked into [x] General Structure of generated code.[x] Role of Stub/Worker method.[x] Structure of State Machine and role of Fields.[x] Implementation of the SetStateMachine method.[ ] Implementation of the MoveNext method. It is now time to look at the most important piece of the puzzle … Continue reading Asynchronous Code – Behind the Scenes – 004

Asynchronous Code – Behind the Scenes – 003

Okay, I wasn't quite realistic in the earlier post when I mentioned we would look at MoveNext in this one. I missed an important clog of the wheel. The SetStateMachine() method. IAsyncStateMachine.SetStateMachine We will only breifly visit the SetStateMachine method here, as the complete picture becomes more clear when we look to details of the MoveNext() method. So how does the SetStateMachine method … Continue reading Asynchronous Code – Behind the Scenes – 003

Asynchronous Code – Behind the Scenes – 002

In the earlier part of this series, we reviewed the generic structure of decompiled async code, especially the stub method. In this part, we would continue our explore of async code and look into the State Machine. We would not delve deep into the most important MoveNext() method yet, we will first familiar with the different parts … Continue reading Asynchronous Code – Behind the Scenes – 002

Asynchronous Code – Behind the Scenes – 001

If you were to ask me what was the biggest milestone in .Net development, then my choice would definetly be .Net 5.0 - especially the introduction of the async/await. The more you learn about the underlying working, you cannot but stop and admire the efforts done by the lang uage developers to make our life easier. … Continue reading Asynchronous Code – Behind the Scenes – 001

Why avoid Conversion Operators

No doubt that the Conversation Operators makes developers life easier by bring in a kind of substitutability, but it comes with a price. If not properly designed/used, it could result in subtle errors that can be easily ignored. Consider the following code. We have a class called Car, which exposes a single property - MakerName. We … Continue reading Why avoid Conversion Operators

Nominal Vs Structural Type System

Anonymous Types and Tuples might look very similar, but there is one significant difference which separates them. As always, nothing can be more explanatory than writing code. Consider the above code. What could be the output ? Are both false or are both true ? Interestingly, the output is as follows. Though syntactically similar, both … Continue reading Nominal Vs Structural Type System

Benchmarking Span<T> Performance

Span<T> is yet another addition to C# 7.x and is particularly useful in developing memory intensive applications.  So what is Span all about ?   As Microsoft describes it, Span<T> is a new value Type which enables the representation of contiguous regions of arbitrary memory, regardless of whether the memory is associated with a managed … Continue reading Benchmarking Span<T> Performance