c# - Force to call virtual base function instead of the overriden one -


In the following example fails "test that the v1 function is called". Is there a way to emphasize the basis implementation of "runfunction" through a frequency of "virtual v2"?

  class V1 {public virtual string runfunction ("}" "V1"; }} Class V2: V1 {public override string runfunction () {return "V2"; }} [Test] Public Zero Testcall () {var v1 = (v1) New V2 (); Var v2 = new v2 (); Assurance ITTru (v1. Runfunction) == "V1", "Test that the V1 function was called"); Confirm. Trust (v2.RunFunction () == "V2", "Test that the v2 function was called"); }  

Thanks for watching, boys and girls.

The complete point of class heritage is that it allows you to override the selected base class behavior . You can use the V2 to use the base to call in the base-class code from V1 , but you can not do outside the class Do it As a quick example of usage:

  class V2: V1 {public override string runfunction () {return base.RunFunction ()); }}  

Alternatively you can instantiate an example of V1 :

  var v1 = new V1 () ;  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -