score:5
Accepted answer
An alternative to Enumerable.Any that doesn't use Linq is List.Exists:
if (_myStructList.Exists(x => x.Name == "DAMN!")) ...
score:13
Try the Any()
method in LiNQ:
using System.Linq;
if(_myStructList.Any(x => x.Name == "DAMN!")) ...
Contains()
is a declared method of List<>
and it expects an object as a parameter and uses equals to compare the objects.
Source: stackoverflow.com
Related Articles
- LINQ Source Code Available
- Performing LINQ operations on List<struct>
- creating Linq to sqlite dbml from DbLinq source code
- source code for LINQ 101 samples
- c# Linq or code to extract groups from a single list of source data
- Convert string[] to int[] in one line of code using LINQ
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- Linq code to select one item
- How are people unit testing code that uses Linq to SQL
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- Syntax to execute code block inside Linq query?
- Array operations with n-dimensional array using LINQ (C#)
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- linq Can't perform Create, Update, or Delete operations on 'Table(req)' because it has no primary key
- Are linq operations on concurrent collections thread safe?
- Best open source LINQ provider
- Is there a good source that gives an overview of linq optimizations?
- Does this LINQ code perform multiple lookups on the original data?
- LINQ operations on IDictionary
- How to understand the following C# linq code of implementing the algorithm to return all combinations of k elements from n
- LINQ WHERE method alters source collection
- Performing part of a IQueryable query and deferring the rest to Linq for Objects
- Performing a Parent then Child sort in Linq
- Where can I view LINQ source code?
- Suggestions for designing complex LINQ code
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- Left outer join using LINQ -- understanding the code
- How to pass LinQ Expressions from F# to C# code
- How to reuse a linq expression for 'Where' when using multiple source tables
- Avoiding code repetition when using LINQ
- Finding combinations of list of lists that add up to a target number
- Getting count of values in dictionary using LINQ
- Linq PredicateBuilder - Multiple ORs
- Reset identity Column to 0
- Extension methods and compile-time checking
- How to delegate parts of a where clause to a different area
- How to execute nested query in Linq
- Check if two lists contain the same numbers using LINQ
- LINQ to Entities does not recognize the method 'Boolean ToBoolean
- LINQ select items incide List of Lists
- Why does IQueryable implement IEnumerable?
- Get a string out of Linq query result
- Distinguish EF query and LINQ query
- Chaining method calls in Expression Tree at runtime
- Can LINQ construct and return a multidimensional array
- LINQ Multiple Insertion
- Unable to search a SQL database under ASP.NET
- Data in Linq query not in join is not in output to json only those that are related in 2 classes are showing up
- Delete Wildcard Row in Azure Table Without Query
- How to select a column after GroupBy in LINQ?