C# Null – Which types can accept null?

added by daniewat82
5/10/2010 2:43:33 PM


A few days ago someone asked me which types can accept null and also how could this be determined at runtime. After a quick Google and some chit chat we found that only if the variables type is not a value type or the variables type has a generic type definition of Nullable<> can the variable accept null . This is really helpful to know when you are dynamically invoking methods at runtime and you are not sure if the methods parameters will accept the passed in values.