Enumeration extension methods

前端 未结 7 1198
长发绾君心
长发绾君心 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:

     _
    Public Sub EnumExtension(ByVal s As Enum)
    End Sub
    

提交回复
热议问题