Suggestion: Add support for constants in C# (and VB.net etc.) interfaces
It is rather unfortunate that C# doesn’t support constants in interfaces, whereas Java does.
If IL (intermediate language) that C# usually compiles to (when not using AOT that is like in .NET Native or Xamarin iOS) doesn’t support this, then the compiler could create a special sealed class to carry the constants.
Then, wherever they’re used via the interface it could get them via that class. This would happen internally without the programmer noticing. The programmer should be able to access the constants using:
SomeClass.SomeConstant, where SomeClass implements ISomeInterface
just SomeConstant when the code is inside the body of SomeClass that implements the ISomeInterface
just SomeConstant when there is a “using static” statement (that newer C# has introduced) like “using static ISomeInteface” or “using static ISomeClass”
You can vote up this suggestion at: