Just saw few tutorials and was quite confused that authors sometimes uses both properties with no restrictions and public fields. I cannot see any reason for doing that. Should not I use it just everytime just to be consistent with “standard”?
class A
{
public bool B;
private bool c
public bool C
{
get
{
return c
}
set
{
c=value;
}
}
}
Using public fields is almost always a bad idea. Just use properties.
You should also be aware of automatically implemented properties (introduced in C# 3), which allow your
Cproperty to be written as: