Hey man, thanks for the input but can you link any web sources that support the following statement you made: "Literals are similar, when you type "Richard" you are telling the compiler to instance a String type object with the given content and 24 is telling the compiler to instance a Int32 object with the value of twenty-four."
Is there any C# Microsoft documentation that supports such argument?
No, I can't think of a link that directly says this. It is kind of assumed that one would understand that a string literal is a string object. If you need proof, as I said in my post, Console.WriteLine("Richard".GetType()); will show that a string literal is of the type System.String and Console.WriteLine(24.GetType()); will show a integer literal is of type System.Int32.
If you have to have a link, I guess the Strings page of the C# Programming Guide implies it by showing a string variable being initialized with a string literal:
// Initialize with a regular string literal.stringoldPath="c:\\Program Files\\Microsoft Visual Studio 8.0";
Likewise, the Integral Numeric Types page of the C# reference makes it about as clear as can be that numeric literals are of the Int32 type unless they have a literal suffix that declares them as another type.
inta=123;System.Int32b=123;
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey man, thanks for the input but can you link any web sources that support the following statement you made: "Literals are similar, when you type "Richard" you are telling the compiler to instance a String type object with the given content and 24 is telling the compiler to instance a Int32 object with the value of twenty-four."
Is there any C# Microsoft documentation that supports such argument?
No, I can't think of a link that directly says this. It is kind of assumed that one would understand that a string literal is a string object. If you need proof, as I said in my post,
Console.WriteLine("Richard".GetType());
will show that a string literal is of the typeSystem.String
andConsole.WriteLine(24.GetType());
will show a integer literal is of typeSystem.Int32
.If you have to have a link, I guess the Strings page of the C# Programming Guide implies it by showing a string variable being initialized with a string literal:
Likewise, the Integral Numeric Types page of the C# reference makes it about as clear as can be that numeric literals are of the Int32 type unless they have a literal suffix that declares them as another type.