Is there any use to instantiating an enum with new?

new T(), when T is a value type, is not a boxing operation. It is the same thing as default(T). Foo x = new Foo();, Foo x = default(Foo), and Foo x = Foo.Bar; all do exactly the same thing.

Reference:

Initializing Value Types

int myInt = new int();

–or–

int myInt = 0;

Using the new operator calls the default constructor of the specific type and assigns the default value to the variable. In the preceding example, the default constructor assigned the value 0 to myInt. For more information about values assigned by calling default constructors, see Default Values Table.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)