I had this question on an interview and I was wondering what would you give as answer if you had the same question. Please don't test the program in the IDE.
public class MyClass
{
private int _myInt;
public int MyInt
{
get { return _myInt; }
set { _myInt = value; }
}
public MyClass()
{
MyInt = 1;
}
}
What should this program print on the screen ? the more important is Why !
var myClass = new MyClass();
myClass.MyInt += myClass.MyInt;
myClass.MyInt = myClass.MyInt +++ 2;
Console.WriteLine(myClass.MyInt);