-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: enum to act like types #3704
Comments
This will only be useful for virtual methods (maybe properties could be nice), and the only one possibly worth changing is
|
Maybe via extension methods? |
|
@jasonwilliams200OK I was semi-agreeing, not actually asking a question. Sorry it was from a mobile, without a proper keyboard I tend to be rather terse. I'm not sure if this is a great idea or not, but I'm willing to accept it does have useful applications, and fit within the current paradigm if done as extension methods and not as inline member methods. |
The value this would add is that it eliminates the need to define a separate class of extension methods. It also allows you to define properties, which cannot be done today with extensions. |
We are now taking language feature discussion on https://github.com/dotnet/csharplang for C# specific issues, https://github.com/dotnet/vblang for VB-specific features, and https://github.com/dotnet/csharplang for features that affect both languages. See also #18002 for a general discussion of closing and/or moving language issues out of this repo. This specific request is now being tracked at dotnet/csharplang#297 |
It would be very useful if C# enums act like classes, so we can add methods within the enum's block scope:
Java:
C#:
Reference: http://www.25hoursaday.com/CsharpVsJava.html#enums (I modified the C# example with extensions)
The text was updated successfully, but these errors were encountered: