If a struct is a value type why can I new it?

Sachin Kainth picture Sachin Kainth · Mar 23, 2013 · Viewed 12.3k times · Source

In C# structs are value types, but I am able to new them as if they are reference types. Why is this?

Answer

BoltClock picture BoltClock · Mar 23, 2013

Because they have constructors.

The new operator doesn't mean "this is a reference type"; it means "this type has a constructor". When you new something you create an instance, and in doing so you invoke a constructor.

For that matter, all value and reference types have constructors (at the very least a default constructor taking no args if the type itself doesn't define any).