sorry, my english is poor. how to create MyGeneric object, and allow T is null? thanks very muck.
public class MyGeneric<T>
{
public int result { get; set; }
public string message { get; set; }
public T data { get; set; }
}
//...how to create MyGeneric object, and allow T is null?
var myGeneric = new MyGeneric<null> {
result = 1,
message = ""
};
Console.WriteLine(myGeneric.result);
nullis not a type. Why do you need this? What are you trying to do? do you want the value ofdatato be null?MyGeneric<string>?. The default value ofstringisnull.