I wonder, in C# I could declare ( often I see such style from code reviews ) like this:
string myVarName
{
get
{
return myVarName;
}
set
{
myVarName = value;
}
}
But many people tell, that is better, than just string myVarName;
declaration as not a property.
I'm becoming confused sometimes, because I often see such a style in code listings.
Why is it better? Are properties inlined
in addition to the hint to the JIT-compiler
that the function should be compiled inline into where it is used avoiding a function call overhead?
Or I can win with some performance?
As for the code-style, I like more simple variable declaration not in property style.
As for the property, I can see only the best advantage in some default manipulations/triggers. E.g.: I need to store the half value in property from incoming value or smth like that...
Maybe I'm not right at all. Am I right or not?
Thanks!