Is it possible to restrict a generic parameter to just accept nullable types? [duplicate]
Possible Duplicate:
Nullable type as a generic parameter possible? Is creating a C# generic method that accepts (nullable) value type and reference type possible?
In c# I would like to restrict my generic method to accept only nullable types. Is that possible?
public 开发者_C百科T Method<T>() where T : somesortofnullablerestriction
{
...
}
You can do this.
public Nullable<T> Method<T>()
{
}
精彩评论