Some times, I see classes contains properties declared like this:
public int MyProperty { get; set; }
Other properties are declared like this:
private int myVar;
public int MyProperty
{
get { return myVar; }
set { myVar = value; }
}
I come from Java background, so, I cannot Understand well the second (full) declaration.
Why we should have a private part and a public part in the second case? In which case we use the first declaration rather than the second (or the inverse). can any one explain any other differences?