Generics C# No Boxing Conversion - No Implicit Conversion -
i'm going try make clear possible!
the end goal being able access protected method within abstract class. method inherited abstract class too.
the abstract class has generic, need class generic (ie creating generic adapter).
here abstract class (well similar structure).
public abstract class myabstract<t> : abaseclass<t> t : someclass { }
here base class inherited abstract class(has method need)
public abstract class abaseclass<t> : anotherbase, idisposable t : someclass, someclass2 { protected void foo(t somevar); }
the classes above within dll, not have access to.
here's trying do, need in right direction!
public mainclass<t> : myabstract<t> t : someclass { public void somefunct() { this.foo(avariable); } }
your class should this:
//uncomment ", new()" if want create new instance within somefunct method public class mainclass<t> : myabstract<t> t : someclass//, new() { //you don't have pass param if you'd prefer create in method public void somefunct(t param) { //uncomment (and ", new()" in class declaration) //if want create new t instead of passing 1 in //var instance = new t(); this.foo(param); //or use "instance" above } }
Comments
Post a Comment