Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

169
Views
Contains half a tuple

How can I check if a list contains a tuple partial match?

var tuples = new List<(int, int)>( new [] { (1, 1), (1, 2), (3, 4), (4, 2) } );
tuples.Contains((3, _));
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Using Linq:

var tuples = new List<(int, int)>(new[] { (1, 1), (1, 2), (3, 4), (4, 2) });
if (tuples.Any(x => x.Item1 == 3))
{
   //....
}
over 4 years ago · Santiago Trujillo Report

0

You could write a custom Contains function, but a .Where will work just fine:

using System.Linq;
[...]

tuples.Where(tup => tup.Item1 == 3);
over 4 years ago · Santiago Trujillo Report

0

You can use the pattern matching is operator, which is very close to the syntax you had in mind:

tuples.Any(x => x is (3, _));
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!