Steve Fenton


You can subscribe to the Programming category micro-feed.

C# Namespace Declarations

Unlike my recent article on Global Using Statement and Code Clues, the new namespace declarations have no trade offs and you should just auto-fix them in your whole project and move on with your life. Here’s how we do namespace before namespace declarations: namespace Fenton.Sample.UI { public class Example { } } …and here is […]

Stripping Times from Dates in C#

This is a surprisingly common problem in C#, where you need to take a DateTime and strip off the “time” bit to leave you with a representation of a day. Currently, you can do it by creating a new DateTime and passing only the parts you want to keep, like year, month, and day. DateTime […]

Type Coercion vs Type Conversion

The key difference between type coercion and type conversion is that type coercion is always implicit, whereas type conversion can be either implicit or explicit. In other words, “type conversion” refers to the general process of changing a type, whereas type coercion refers more specifically to the implicit conversion of a type. We can further […]

Counting a Non-Generic IEnumerable

You rarely come across them in 2021, but there is such a thing as a non-generic IEnumerable. They exist in System.Collections rather than System.Collections.Generic. Since .NET 2 pretty much everyone is full-on using generics as they are the best thing since curly-braces… but occasionally you find one and even more rarely you need to count […]