Numeric constants in enum (c#)

后端 未结 5 1327
既然无缘
既然无缘 2021-01-24 05:06

I\'m creating this selectbox in a SharePoint web part and need to have a drop down with the current version so I need to use an Enum.

public enum SelectVersionEn         


        
5条回答
  •  囚心锁ツ
    2021-01-24 05:14

    You can add an extension method to your enum like any other type.

    So you could create an extension for your SelectVersionEnum to help you get the enum values in the right format...

    public static class SelectVersionEnumExtension
    {
         public static int Version(this SelectVersionEnum enumValue)
         {
             return 0; // Obviously you should return something meaningful here..
         }
    }
    

    This gives you a lot of flexibilty.

提交回复
热议问题