Should the new static abstract members not be enforced in abstract classes? #7730
Unanswered
SoftCircuits
asked this question in
Language Ideas
Replies: 2 comments 4 replies
-
Related to #5783 and I agree that it's annoying. A (poor) workaround is this: public interface IReport
{
static abstract string Name { get; }
static abstract string Description { get; }
}
-public abstract class Report : IReport
+public abstract class Report
{
// Additional functionality
}
-public class TestReport : Report
+public class TestReport : Report, IReport
{
public static string Name => "Name";
public static string Description => "Description";
} |
Beta Was this translation helpful? Give feedback.
4 replies
-
This has always been the case with interfaces and abstract classes. The required members of the interface aren't inherited as "abstract" by the abstract class, they need to be explicitly defined: public interface I {
void M();
}
public abstract class C : I { // error CS0535: 'C' does not implement interface member 'I.M()'
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to put off implementing
static abstract
members to my derived class, as shown in the following example.Here, I want
TestReport
to defineName
andDescription
. So I madeReport
abstract.But I still get an error for
Report
because it didn't defineName
andDescription
.Beta Was this translation helpful? Give feedback.
All reactions