creating a new type
how do Integers for example do it, that they are a struct under the hood but instead of calling a constructor like they can be assigned like
8 Replies
and can the user replicate this?
Primitive types like int are special cases that I assume are handled by the C# compiler
It isn't really possible to do much custom syntax unless you want to write a preprocessor or something
shite
thanks
You can create custom types, but the syntax will use the new keyword like you have in the first line
there is also implicit/explicit conversion:
⤴️ will print
Exaample(5)
thats basically like casting, if that was explicit
instead of implicit
u would have to write Example e = (Example)5;
its basically a casting operator overrideAlso about ints, I the
int
constructor is never called when you do int i = 0;
. Again ints are special.