There is nothing already suitable for you with the Enum.GetValues() method. If you want to use attributes, you can create your own attribute and use it through reflection:
public class BrowsableAttribute : Attribute { public bool IsBrowsable { get; protected set; } public BrowsableAttribute(bool isBrowsable) { this.IsBrowsable = isBrowsable; } } public enum DomainTypes { [Browsable(true)] Client = 1, [Browsable(false)] SecretClient = 2, }
And then you can use reflection to check for custom attributes and generate an Enums list based on the Browsable attribute.
source share