Difference between using enum or AvailableValues attribute

Hi all,

I just want to know what is the difference between using

        [Display(Name: "Mode", Description: "Discover mode",
            Order: 2.2, Group: "Input Parameter")]
        public EnumMode Mode{ get; set; } = EnumMode.Fast;

and

       [Display(Name: "Mode", Description: "Discover mode",
            Order: 2.2, Group: "Input Parameter")]
        [AvailableValues("AvailableEnumMode")]
        public EnumMode { get; set; } = EnumMode.Fast;

        [Browsable(false)]
        public List<EnumMode> AvailableEnumMode => new List<EnumMode>
        {
            EnumMode.Fast,
            EnumMode.Slow
        };

Using the Keysight TAP Editor, it seems to have the same functionality to me. Just want to understand if there is any difference worth noting!

Hi @antonio.quizon,

It’s a good question. In this specific case there is no difference. But you could use AvailableValues to select only the subset of enum values you want the user to select between.

Also AvailableValues works with many object types and is not limited to enum types.

1 Like