im learning c# and i cant underestand that why are the results different in the following code:
public class Thing
{
public object Data = default(object);
public string Process(object input)
{
if (Data == input)
{
return "Data and input are the same.";
}
else
{
return "Data and input are NOT the same.";
}
}
}
and inside main method:
var t1 = new Thing();
t1.Data = 42;
Console.WriteLine($"Thing with an integer: {t1.Process(42)}");
var t2 = new Thing();
t2.Data = "apple";
Console.WriteLine($"Thing with a string: {t2.Process("apple")}");
and the output is:
Thing with an integer: Data and input are NOT the same.
Thing with a string: Data and input are the same.