Do you use Public/Protected Properties instead of Public/Protected Fields?

Updated by Tiago Araújo [SSW] 2 years ago. See history

123
No component provided for introEmbed
public int Count;

❌ Figure: Figure: Bad code - Variable declared as a Field

public int Count
{
get
{
return _count;
}
set
{
_count = value;
}
}

✅ Figure: Figure: Good code - Variable declared as a Property

We agree that the syntax is tedious and think Microsoft should improve this.

Acknowledgements

Adam Cogan
Related rules

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.

We open source.Loving SSW Rules? Star us on GitHub. Star