The string does not overload the + operator. This is a C # compiler that converts a call to a + operator to a String.Concat method.
Consider the following code:
void Main() { string s1 = ""; string s2 = ""; bool b1 = s1 == s2; string s3 = s1 + s2; }
Produces IL
IL_0001: ldstr "" IL_0006: stloc.0 // s1 IL_0007: ldstr "" IL_000C: stloc.1 // s2 IL_000D: ldloc.0 // s1 IL_000E: ldloc.1 // s2 IL_000F: call System.String.op_Equality //Call to operator IL_0014: stloc.2 // b1 IL_0015: ldloc.0 // s1 IL_0016: ldloc.1 // s2 IL_0017: call System.String.Concat // No operator call, Directly calls Concat IL_001C: stloc.3 // s3
Spec calls this here. 7.7.4 The add statement , although it doesn't talk about calling String.Concat . We can assume that this is a detail of the implementation.
source share