【问题标题】:How can I get set of Enums except one using Linq?除了使用 Linq 的枚举之外,我如何获得一组枚举?
【发布时间】:2014-06-16 06:14:58
【问题描述】:

我有一组枚举

public enum SyncRequestTypeEnum
{
 ProjectLevel=1,
 DiffSync=2,
 FullSync=3
}

我想在除 ProjectLevel 之外的下拉列表中显示这些枚举。 我可以使用 linq 获取这些详细信息吗? 有人可以帮忙吗?

【问题讨论】:

标签: c#


【解决方案1】:

可能是这样的:

var result = Enum
        .GetValues(typeof(SyncRequestTypeEnum))
        .Cast<SyncRequestTypeEnum>()
        .Where(w =>w!=SyncRequestTypeEnum.ProjectLevel)
        .ToList();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-11
    • 1970-01-01
    • 2015-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-15
    相关资源
    最近更新 更多