How to Inherit method but with different return type?

前端 未结 10 1071
北荒
北荒 2021-01-17 19:20

Given the following classes:

ClassA
{
     public ClassA DoSomethingAndReturnNewObject()
     {}    
}

ClassB : ClassA
{}

ClassC : ClassA
{}
10条回答
  •  庸人自扰
    2021-01-17 19:47

    No, the feature you mentioned is called return type covariance. It's not supported in C#.

提交回复
热议问题