What CLR do when compare T with null, and T is a struct?

Posted by Fujiy on Stack Overflow See other posts from Stack Overflow or by Fujiy
Published on 2010-03-19T11:20:33Z Indexed on 2010/03/19 11:21 UTC
Read the original article Hit count: 142

Filed under:
|
|
    private static void SaveOrRemove<T>(string key, T value)
    {
        if (value == null)
        {
            Console.WriteLine("Remove: " +key);
        }

.... }

If I call passing 0 to value: SaveOrRemove("MyKey", 0), the condition (value == null) is false, then CLR dont make a (value == default(T)). What really happens?

© Stack Overflow or respective owner

Related posts about clr

Related posts about c#