locked
static T <T> question RRS feed

  • Question

  • User-1833521293 posted

    How does GetDefaultValue<T> return a zero or all types?  Thanks.

    int i = GenericsUtilities.GetDefaultValue<int>();
    Debug.Assert(i == 0);
    string s = GenericsUtilities.GetDefaultValue<string>();
    Debug.Assert(s == null);
    
    public static T GetDefaultValue<T>()
        {
            // return ???
        }
    

    Sunday, September 3, 2017 12:02 AM

All replies