class demo
{
int x=10;
public demo()
{
}
static void Main()
{
Console.WriteLine(new demo().x); //1st line
new demo().x = 20; //2nd line
Console.WriteLine(new demo().x);
demo d2=new demo();
d2.x = 30; //3rd line
Console.WriteLine(d2.x);
Console.ReadLine();
}
}
What is the difference between 1st,2nd and 3rd line ??? Why the value is not assigned in 2nd line where as it is assigned in 3rd line ???

VulpesRank #55 · 29.2K reputationPosted Mar 18, 2013, 10:08 AM EDT
If you do assign the object in the second line to a variable and then use that, you will get different values: