Properties are actually methods in C#. And what you have shown in the code is an auto-implemented property. It's a sytantic sugar for this:
// this backing field is generated by compiler
int alertLevel;
public int AlertLevel
{
get { return alertLevel; }
private set { alertLevel = value; }
}
And it's another syntactic sugar for this:
int alertLevel;
public int getAlertLevel()
{
return alertLevel;
}
private void setAlertLevel(int value)
{
alertLevel = value;
}
So you write less code, and you get same behaviour.That's the point.Compiler does the hard work for you.