Nullable reference types: How to specify “T?” type without constraining to class or struct

后端 未结 3 1750
别跟我提以往
别跟我提以往 2020-11-28 09:59

I want to create a generic class that has a member of type T. T may be a class, a nullable class, a struct, or a nullable struct. So basically anyt

3条回答
  •  感情败类
    2020-11-28 10:13

    class Box {
        public T! Value { get; }
    
        public Box(T! value) {
            Value = value;
        }
    
        public static Box CreateDefault()
            => new default!;
    }
    

    What does null! statement mean?

提交回复
热议问题