C#6 brought some nice short-hand ways of handling properties. I really like them, because they take away much boilerplate code. But as with all new tools, it’s easy to use them wrongly until they are familiar. These are two attempts to declare a readonly property that preserves the time stamp of when the object was… Continue reading Expression Bodied vs. Auto Read-Only Properties
Tag: Language Basics
Internal Classes and Members
What’s the use for the internal access modifier in C#? It’s not as common to use as public, protected or private. It wasn’t until I started some serious stand alone library work that I fully started to appreciate and use internal. All was fine and I was happy with my use of internal. Until I… Continue reading Internal Classes and Members
Code Coverage and Nullable
Comparisons of Nullable<T> types and code coverage can give some unexpected, but logical results. Earlier this week I posted a small Puzzle showing the problem. The light blue shade of the return statements indicate that they have been executed. So both branches of the if statement have been covered. But the light pink shade of… Continue reading Code Coverage and Nullable
A Code Coverage Puzzle
A simple comparison is marked as not completely covered, although both branches of the if statement have been covered!?! How is that possible? This is a small function I’ve created, which is also covered by unit tests. The light blue shade of the return statements indicate that they have been executed. So both branches of… Continue reading A Code Coverage Puzzle
.NET ==
and .Equals()
Equality might look like a simple concept at a first glance, but looking deeper it isn’t. In C# objects can be compared with the == operator, with the Equals(Object) member, with the Object.Equals(Object, Object) method or using custom comparators that implement one of or more of the IEquatable<T>, IComparable, IStructuralEquatable or IStructuralComparable interfaces. There’s also… Continue reading .NET ==
and .Equals()