Enumeration extension methods

前端 未结 7 1197
长发绾君心
长发绾君心 2020-12-01 07:09

In vs2008, is it possible to write an extension methods which would apply to any enumeration.

I know you can write extension methods against a specific enumeration,

相关标签:
7条回答
  • 2020-12-01 08:02

    Yes, you can. The target extenstion type is of type Enum. In C#, this would be done as:

    public static void EnumExtension(this Enum e)
    {
    }
    

    or like this in VB:

    <Extension()> _
    Public Sub EnumExtension(ByVal s As Enum)
    End Sub
    
    0 讨论(0)
提交回复
热议问题