c# Abstract Generic Class inheriting from Abstract Generic Class -


I am trying to create an intangible general square which is derived from another abstract general class.

What I've done so far

  Public Intangible Class Base Class {Public Long ID} Private Set; } Public Base Class (long id) {this.Id = id; }} Public Essential Class Base Class & lt; T & gt; : Base Class where T: Base Class {Secure Base Class (Long ID): Base (ID) {} Get Public Stable T (Long ID) {T Object; TryGet Return (ID, Out Item)? Items: Default (T); } Public Stable Bull Triget (long id, out t item) {items = null; // This is where I call the cache, but for this example I have removed, so it will compile if (item! = Null) {back true; } Else {// Call TryGetFallback return method false; }} Protected abstract T TryGetFallback (long id); } Public Essentials DerivedClass: Base Class & lt; DerivedClass & gt; {Get public string name { Private set; } Public DerivedClass (long id, string name): base (id) {this.Name = name; }} Public class DerivedDerivedClass: DerivedClass {Safe override DerivedDerivedClass TryGetFallback (long id) {// Get HetalTpt Fallback}}   

The TryGetFallback method on DerivedDerivedClass causes a compiler error.

Firstly, you should call your BaseClass & lt; T & gt; Re-type obligation

  Public Essential Class Base Class & lt; T & gt; : BaseClass where T: new () {// snip}   

then you can use it in your derived class, for example I would call it int Normal Type Parameter:

  Public Essentials DerivedClass: Base Class & lt; Int & gt; {// snip}   

And now if you compile it, you will be warned that the member member of 'derivedDerivedClass' inherited from the' base class & lt; Int>. TryGetFallback (long) '

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -