DEV Community

Discussion on: How to get rid of the `new` C# keyword

Collapse
 
mrpmorris profile image
Peter Morris

Might be better to have implicit conversion from string/int to the property type, but not from the property type back.

Collapse
 
kiritchoukc profile image
KiritchoukC

Maybe I didnt get it right but if you do that you won't get type checking anymore.
Because then a string can convert to a Name or a FirstName.

Collapse
 
mrpmorris profile image
Peter Morris

Yes it can, but you can just as easily pass the wrong string value to your constructor.

It's not string to FirstName you are trying to prevent, it is FirstName to LastName.