c# - Generics Inheritance and field declaration (class where T : class) -



c# - Generics Inheritance and field declaration (class<T> where T : class<T>) -

i have next class definition:

public abstract class baseexample<t> t : baseexample<t> { public abstract t clone(t original); }

and inheritances

public class example01 : baseexample<example01> { public override example01 clone(example01 original) { homecoming this; // not actual implementation } } public class example02 : baseexample<example02> { public override example02 clone(example02 original) { homecoming this; // not actual implementation } }

how declare variable type or base of operations class? since next declaration doesn't compile:

private baseexample<t> declarationa; private baseexample<t> declarationa; private baseexample declarationb;

it won't work whatever assign generic type t cannot ever baseexample<t>.

baseexample<int> declarationa;

in case above int can't baseexample<int> (int != baseexample<int>)

c# generics inheritance

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -