How can I return NULL from a generic method in C#?
Three options: Return default (or default(T) for older versions of C#) which means you’ll return null if T is a reference type (or a nullable value type), 0 for int, ‘\0′ for char, etc. (Default values table (C# Reference)) If you’re happy to restrict T to be a reference type with the where T : … Read more