Checking for nulls in C# is tedious, but C# 6 gave us the null-conditional operator. Let’s see what we can do with it!
The longer I write software, the more I come to appreciate clear code. String interpolation in C# is just one more way to help us do that.
There’s a lot of ways to make our code work for us. Let’s check out using the nameof operator to avoid magic strings.
All programming languages have gotchas to trip you up, and C# is no exception. Today, let’s check out the subtle (but significant) difference between “throw” and “throw ex”.
This error might look a little cryptic at first glance, but it’s fairly descriptive in explaining what’s wrong. You’re likely to come across this one before your first cup of coffee.
Did you know most languages have a way to pass around code to other functions, so you can call (invoke) it in other parts of your application? In C#, it’s called a delegate.
One of the many nice functions in LINQ is a single word that iterates through a collection, returning true if at least one item in the collection matches the condition you specify. But what’s the opposite of the Any keyword in LINQ?
Porting .NET Framework code to .NET Standard has been a learning experience, with some challenges too. This time I had a .NET Standard library that expected an application config file, but loading one from an NUnit test suite proved to be more difficult than it sounded at first.
I was upgrading some code to use string interpolation, a feature introduced in C# 6, when I ran into a small snag with DateTimes and a format string stored as a constant.
Ever thought it’d be convenient to attach metadata to your code at design time, then read it at runtime? Attributes let you do just that - to methods, classes, tests, enumerations, and more. Use reflection to read them at runtime and take some action. Here’s a few examples for the uninitiated…
It’s common to compare two objects in C# for equality, such as for a save operation. Let’s take a closer look at how we define what equal means.
We use implicit and explicit conversion in C# all the time, without even realizing it. Let’s learn more about them and look at examples of each.
The Obsolete attribute on a class is ignored when an interface is involved. It caught me by surprise, but makes sense. Let’s see why.
Let’s combine the SqlDataReader’s GetFieldValue and GetOrdinal methods into an extension method that lets us pass a column name and get back a specific type.