On Feb 9, 4:43 pm, "Lee Grissom" <lee dot grissom at quest dot com>
wrote:
public void SomeGenericClassConstructor(T item){}
Very simple question: How do I pass in a null value as the argument?
Generics require something different than what I'm use to.
I'm not sure that I understand your question.
Do you mean that this is a method within a generic class:
public class SomeGenericClass<T>
{
public void SomeGenericClass(T item) { }
}
? If this is so, then there is no problem passing null to the
constructor. Of course, you have to instantiate the generic class to a
particular class, first:
SomeGenericClass<stringmyInstance = new
SomeGenericClass<string>(null);
Or, are you talking about a generic method, in which case I think that
your syntax was wrong:
public void SomeGenericClassConstructor<T>(T item) { }
In that case, you can still pass null as the argument, but you have to
instantiate the method:
SomeGenericClassConstructor<string>(null);
Or was it neither of these?