My question is how "object.ToString()" method evaluate in string concatenate statement?.
I mean if write code like-:
class Employee
{
public string Name{get; set;}
public override string ToString()
{
return string.Format("Employee Name {0}", Name);
}
}
static void Main()
{
Employee emp = new Employee() {Name = "Ni3"};
string result = "Result = " + emp;
Console.WriteLine(result);
}
it yields -
Result = Employee Name Ni3
so compiler transforms the statement like this -:
string result= String.Concat("Result = ",emp.ToString());
or there is another reason.