c# - string = string + int: What's behind the scenes? -
You can add a string in C # and say, an integer:
string Sth = "something" + 0;
My questions are:
-
By assuming the fact that you can add a string and an integer, the cables like C # Does not allow it to start:
string sth = 0; // Error: The source type 'int' can not be changed to target type 'string'
-
How the C # # forms of string Is it
0.ToString ()
or(string) 0
or something else? - How to get the answer to the last question?
To make this call, such as:
String sth = String.Concat ("some", 0);
(Note that this particular line will actually be optimized by the compiler)
This method is defined as follows: (Taken from Net Reference Source )
Public Static String Context (object arg0, object arg1) {if (arg0 == null) {arg0 = String.Empty; } If (arg1 == faucet) {arg1 = String.Empty; } Return concat (arg0.ToString (), arg1.ToString ()); }
(This String.Concat (string, string) call
)
To find it, +
line is compiled for whom.
Comments
Post a Comment