score:6
Accepted answer
return Enum
.GetValues( typeof(AnimalCodeType) )
.Cast<AnimalCodeType>()
.Where( v => (int)v > 0 )
.Select( v => v.ToString() )
.ToList();
score:7
This gives you all but the ant (recommended way):
var animalsWithoutAnt = Enum.GetValues(typeof(AnimalCodeType)).Cast<AnimalCodeType>()
.Where(act => act != AnimalCodeType.Ant)
.ToList();
or by using the int-value:
var animalsWithoutAnt = Enum.GetValues(typeof(AnimalCodeType)).Cast<AnimalCodeType>()
.Where(act => (int)act != 0)
.ToList();
Source: stackoverflow.com
Related Query
- Enum values to string list with filter
- Sort String list with Numeric Values
- Linq Query to Compare with List of string values
- I need to compare list with Datatable and filter values using Linq
- Filter Object List with string array list C# lambda expression
- Filter a list of string with wildcard
- How to filter list of dictionary values with criteria
- EFCore Filter on Property With Contains And List of Values
- Filter a generic list with a dynamic condition string with linq
- Filter a List of Strings and select only one occurance of a string with multiple occurance
- List of class objects - Filter class objects with same values using LINQ
- List or Array of String Contain specific word in Html Source Code
- How do I left join a string List and fill in missing values with zeros
- Solid way to filter lists with different values and list sizes
- Filter LINQ To Entities (EF Core) query by List of HashSet of String and Enum
- Checking a list with null values for duplicates in C#
- Replace string values in list
- Converting enum values into an string array
- Check if a string within a list contains a specific string with Linq
- Sorting a list with null values
- Comparing 2 objects and retrieve a list of fields with different values
- Getting unique values from a list of objects with a List<string> as a property
- How to find key value pair in a dictionary with values > 0 with key matching a certain string pattern?
- Use linq expression to filter a dictionary with a list of keys
- How to create a comma delimited string from distinct list of values using LINQ?
- ModelState create List string with Key + ErrorMessage. (LINQ)
- How do you sort a String List by the number of words matched with an Array in Linq
- convert values of List objects to string
- How to convert Dictionary to List with mixing of values and keys?
- List of objects to Dictionary with distinct keys and selected values
More Query from same tag
- How to remove comma characters from a semicolon delimited List<string>?
- How to get a dictionary with Linq where keys are met more than once?
- Problem in creating database through code first approach
- .NET - comma separated appSettings value to list of integers (+ handle empty value)
- Using Where with Lists inside Lists
- C# LINQ - Find object in list between two properties
- fastest way to compare if two ms sql tables are the same
- using if else in Expression Queries c#
- Leaky abstraction in LINQ to SQL EntitySet
- Convert Expression<Func<T, bool?>> to Expression<Func<T, bool>>
- Which kinds of queries is better for querying against conceptual model in Entity Framework?
- Using GetElementsById to search a website
- Element 'group' does not match any field or property of class Gillie.JobCenter.Domain.KeyValueEntity
- How to check CONTAINS with multiple values
- Linq Where Clause with Into
- How should I change this source into LINQ?
- Find next DateTime based on given DayOfWeek List
- use LINQ to find the product with the cheapest value?
- LINQ: Evaluating a function where array elements are matched by index
- Manipulate data on list with date period grouping by date/month
- Linq to SQL VS Entity Framework
- Dynamic Where Linq C#
- Problem in populating a dictionary using Enumerable.Range()
- How do I make LINQ queries to an SQLite database?
- Can I 'flatten' an XDocument with Linq?
- Linq to SQL using multiple DataContexts in a single query
- Read huge table with LINQ to SQL: Running out of memory vs slow paging
- IEnumerable performs differently on Array vs List
- Design of Service Layer and Repositories in Microsoft MVC
- Expression tree for groupby with where clause and than select