Saturday, 15 August 2015

c# - Can members of an inner class be overridden? -



c# - Can members of an inner class be overridden? -

suppose have next class declarations:

public abstract class foo { public class bar { public virtual void dosomething() { ... } } }

is possible override bar.dosomething() in kid class of foo, la:

public class quz : foo { public override void bar::dosomething() { ... } }

obviously syntax doesn't work, possible?

no, can still inherit foo.bar class itself:

public class barderived : foo.bar { public override void dosomething() { ... } }

i sense should explain doing not mean class deriving foo of sudden have inner class of barderived instead, means there class can derived it. there ways of replacing type of class want utilize inner class, example:

public class foo<t> t : foo.bar { private t _bar = new t(); public class bar { public virtual void dosomething() { ... } } } public class barderived : foo.bar { public override void dosomething() { ... } } public class quz : foo<barderived> { ... }

c# .net oop

No comments:

Post a Comment