Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get set of Enums except one using Linq?

Tags:

c#

I have a set of enums

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

I want to display these enums in a drop down list except ProjectLevel. Can I get these details using linq? Can someone help on this?

like image 848
user3356020 Avatar asked Jun 16 '14 06:06

user3356020


1 Answers

Maybe something like this:

var result = Enum
        .GetValues(typeof(SyncRequestTypeEnum))
        .Cast<SyncRequestTypeEnum>()
        .Where(w =>w!=SyncRequestTypeEnum.ProjectLevel)
        .ToList();
like image 106
Arion Avatar answered Oct 12 '22 17:10

Arion