I'm concerned of people always using getter-setter pattern:
public int MyVariable { get; private set; }
public void SomeFunction(){
MyVariable = 10;
}
Which as far as I understand compiles to something like:
private int myVariable;
public int GetMyVariable(){
return myVariable;
}
private void SetMyVariable(int value){
myVariable = value;
}
public void SomeFunction()
{
SetMyVariable(10);
}
Doesn't it impact the program's performance if used frequently? Isn't it better to do like that:
private int myVariable;
public int MyVariable { get {return myVariable; } }
public void SomeFunction(){
myVariable = 10;
}