If you make the class sealed
you won't get the warning either (because the issue is only an issue if you inherit this class and override the member).
Edit after OP comment:
Ah, right. I usually encounter this only when I'm dealing with inherited virtual members. Yads' answer is probably the most useful for you.
Please also note you don't have to make the entire property virtual. Consider this:
List<Grade> Grades {
get { return _grades; }
set { _grades = value; OnGradesChanged(); }
protected virtual OnGradesChanged()
{ }
Usually, you don't want to store the Grades
in a different way in the derived class. You just need to do some updating when it changes. This way, you provide more guidance to the derived class, and you are sure that you can trust the backing field.
P.S.
You are aware that people can edit the List<Grade>
without your classes seeing it? You should consider using ObservableCollection
which includes an event when the collection is changed externally. In that case, you only need to expose a readonly Grades
property.