How do you make an 'enum' that has data tied to it?

前端 未结 6 1903
深忆病人
深忆病人 2021-01-23 02:28

I have a Vote class and one of the properties it can have is a vote type. Such as unanimous, a 3/4 vote, a simply majority, etc. Each type needs to have a string associated with

6条回答
  •  孤城傲影
    2021-01-23 02:56

    public class Vote()
    {
         public VoteType VoteSelectType { get; set; }
    }
    
    public enum VoteType
    {
        [Display(Name = "Enter Text Here")]
        unanimous = 1,
        [Display(Name = "Enter Text Here")]
        threequatervote = 2,
        [Display(Name = "Enter Text Here")]
        simplymajority = 3
    }
    

    Goto here this is pretty much your solution How do I populate a dropdownlist with enum values?

提交回复
热议问题