Generic default or null
extension method to compare generics for default public static bool IsDefaultOrNull(this T value) { return EqualityComparer.Default.Equals(value, default(T)); }
extension method to compare generics for default public static bool IsDefaultOrNull(this T value) { return EqualityComparer.Default.Equals(value, default(T)); }
I’ve got a simple class I use in a framework so the business objects can use different distinct identifiers (DB int, guid, key etc). public class Identifier<t> { private T _value; public Identifier(){ } public Identifier(T value) { Value…Continue Reading →
I’ve been heavily working with generics over the past few weeks for the final re-factor of LiveFlex. Generics are fantastic but they do have some annoying limitations. You can’t, for instance, create a List<T> and add mixed types such as…Continue Reading →