C# 在ASP.NET Core下拉列表中显示部分枚举列表

C# 在ASP.NET Core下拉列表中显示部分枚举列表,c#,enums,asp.net-core,asp.net-core-mvc,C#,Enums,Asp.net Core,Asp.net Core Mvc,假设我有这样一个枚举: public enum ContactPhoneType { [Display(Name = "")] None = 0, [Display(Name = "Home Phone")] HomePhone = 1, [Display(Name = "Cell/Mobile Phone")] CellMobile = 2, [Display(Name = "Work Phone")] Work = 3,

假设我有这样一个枚举:

public enum ContactPhoneType
{
    [Display(Name = "")]
    None = 0,

    [Display(Name = "Home Phone")]
    HomePhone = 1,

    [Display(Name = "Cell/Mobile Phone")]
    CellMobile = 2,

    [Display(Name = "Work Phone")]
    Work = 3,

    [Display(Name = "Family Member")]
    FamilyMember = 4,

    [Display(Name = "Fax Number")]
    Fax = 5,

    [Display(Name = "Other")]
    Other = 6,
}
我只想显示列表中的前6个。我怎么能把最后一个藏起来

为了显示所有项目,我使用了以下代码:

<div class="form-group">
   <label class="col-sm-4 control-label" asp-for="PhoneNumberType"></label>
      <div class="col-sm-6">
        <select asp-for="PhoneNumberType" asp-items="Html.GetEnumSelectList<ContactPhoneType>()" class="form-control"></select>
       </div>
</div>

如果该方法返回的集合继承自
IEnumerable
,则可以使用
Take()
方法按以下方式选择它的前N个元素:

asp-items="Html.GetEnumSelectList<ContactPhoneType>().Take(6)"
asp items=“Html.GetEnumSelectList().Take(6)”
希望有帮助