So for complex types, we can write:
return new MyType ( 5 );
but why can’t we do stuff like (to have symmetry for one):
return new int ( 5 ); return new Int64 ( 5 );
I know only parameterless constructors are provided. What’s the reason for this?
What would be the point? Any of the .NET value types that don’t have a constructor have a literal form. If they didn’t have a literal form, it would be impossible to provide a constructor that takes its type as a parameter.
Since you have the literal, providing a constructor which takes that literal makes no sense.
Without literal, impossible
With literal