C#, implement 'static abstract' like methods -
I recently went to a problem where I think I need a 'static abstract' method I know Why is it impossible, but how do I work around this limit?
For example, I have the abstract element in which there is a description string. Since this string is normal for all instances, it has been marked as static, but I want to get it from this class All classes give their own description of the property so that I consider it the essence:
abstract class abribbes {... public static abstract string description {get;} ...} This is definitely not compiled I would have thought about using the interface but there can not be a static method sign in the interface.
Should I make it only non-static, and always get an example to get that specific specific information?
Thoughts?
The combination of constant and abstract is somewhat meaningless, yes. The idea behind the stable is that there is no need to present an example of a class to use in a member question; However, with the essence, there is an expectation that there is an example of a derived class which provides a concrete implementation.
I can see why you want this type of combination, but the fact is that the only effect would be to deny the use of 'this' or any non-stable member of the implementation. That is, the parent class will direct a restriction in the implementation of the derived class, even if an abstract or a 'static abstract' member (using both of them as a concrete example will require a concrete example to find out the implementation ) There is no implied difference in calling
Comments
Post a Comment