Very interesting question.
Let's look at your example IL code:
ldstr "C:\\" ldloc.0 box int ldstr "\\abc" call string System.String.Concat(object, object, object)
The called function behind is System.String.Concat, which accepts 3 objects!
Let's delve into the .NET source code:
public static String Concat(Object arg0, Object arg1, Object arg2) { Contract.Ensures(Contract.Result<String>() != null); Contract.EndContractBlock(); if (arg0 == null) { arg0 = String.Empty; } if (arg1==null) { arg1 = String.Empty; } if (arg2==null) { arg2 = String.Empty; } return Concat(arg0.ToString(), arg1.ToString(), arg2.ToString()); }
HOW YOU SEE ToString() , it will be called, but later! It's very impressive what the guys at Microsoft are doing!
source share