How can I correctly override a class method / property in a derived class?

Follow This Question -

In the Question class, I have the following properties (here I simplify)

 public class Question : IDisposable, IEquatable<Question>{ protected virtual DataRow Row{ get { return DataTable.Rows[0]; } } public string Value { get { return this.Row.Field<string>("Value"); } } } 

now for the SessionQuestion class I want to save this in the game, but I want to read the Value field from another data table:

 public class SessionQuestion : Question, IEquatable<SessionQuestion>{ protected override DataRow Row { get { return OtherDataTable.Rows[0]; } } } 

Now, if I said something like:

 new SessionQuestion( ).Value 

will return a value from DataTable.Rows[0] or OtherDataTable.Rows[0] ? I want it to return a value from OtherDataTable , so if that doesn't work, what do I need to do, will it work correctly?

0
source share

All Articles