Search:
And I donβt remember ...
Preconception: Each "built-in type" in C # (for example, int , float , char , etc.) is a class, and each class in C # inherits from Object . Therefore, each "built-in type" is inherited from the Object class.
Given this prejudice, I would suggest that to set the double variable, for example, I would need to set some properties using the "normal" syntax. Here is what I mean:
double number = new double(); number.leftSide= 5; number.rightSide = 23; Console.Write(number);
But C # has a special equivalent syntax for creating a double variable (so that it will do what I tried to do above, and not that the code above will actually work):
double number = 5.23;
The compiler understands that a floating point divides the number into two: 5 and 23.
My question is, can I do the same with my own classes. For example, if I have my own Time class (and this is just an example, so please do not suggest using the built-in time classes), I would like to be able to instantiate it as follows:
Time time = 10:25;
And the compiler will understand that the colon divides the number into hours and minutes (which, I assume, are the properties that I need to create in the Time class).
I heard about Roslyn CTP , but I'm looking for a simpler, in-line way to accomplish what I described.
Can I do it?