string = string + int: What's behind the scenes?

Viewed 57280

In C# you can implicitly concatenate a string and let's say, an integer:

string sth = "something" + 0;

My questions are:

  1. Why, by assuming the fact that you can implicitly concatenate a string and an int, C# disallows initializing strings like this:

    string sth = 0; // Error: Cannot convert source type 'int' to target type 'string'
    
  2. How C# casts 0 as string. Is it 0.ToString() or (string)0 or something else?

  3. How to find an answer of the previous question?
2 Answers
Related