Category: C#

Why Developers Don’t Write Unit Tests

When I started my career in software development 22 years ago this year, it seemed that unit testing adoption was rather patchy. Whether you wrote unit tests or not, depended upon the environment you worked in. So most developers only used to write unit tests if they worked on a project which mandated unit testing, […]

Nullable Reference Types

Previous Versions Previously in C#, references have been allowed to be null and they could be de-referenced without null checks. We would then get a NullReferenceException, this happens when we dereference a variable which is set to null. Sometimes we have nulls coming from other parts of the code, which we then discover later when […]

Read-only Auto Properties

In this article I discuss read-only automatic properties. I am going to cover how automatic properties have changed over the releases of C# and along the way show how much more concise the code becomes. Automatic Properties Ever since C# 3.0 came out we had the ability to define automatic properties. Gone were the days […]

nameof Operator

The nameof operator was introduced in C# 6. But before I discuss what the nameof operator is for, I would like to show what life was like before the nameof operator. Life before the nameof operator So back in C# 2, we might have the following code in our constructor: We would have used magic […]