interface eer {
public abstract void S1<T>(T? t) where T : struct;
public abstract void S1<T>(T? t) ;
}
class A1 : eer {
void eer.S1<T>(T? t){}
void eer.S1<T>(T? t)where T:default{}
}
class B1 : A1 {
void eer.S1<T>(T? t) { } //error
void eer.S1<T>(T? t) where T : default { } //error
}
So my B1
class implements the eer
interface indirectly but when I try to explicitly implement the S1<T>(T? t) where T: struct
and S1<T>(T? t)
methods inside B1
I get the error stating that the containing type does not implement the eer
interface.
I am guessing this is beacuse in some situation there would be some ambiguity maybe.
Could you please tell me why is that so (It does not make sense to me now)?
Just add to B1
the eer
interface. The explanation is that A1
must implement the eer
interface, but the B1
has nothing to do with it. When u wanted to implement the methods in the explicit mode (eer.S1) the B1
doesn't know that u want to implement eer
interface because it was not defined for the B1
class.
class B1 : A1, eer
{
void eer.S1<T>(T? t) { } //error
void eer.S1<T>(T? t) where T : default { } //error
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.