-2

I was wondering if it's possible to search a list I created such as:

static void Main(string[] args) {
    int count = 0;
    string trans, descr;
    List<ErrorInfo> errList = new List<ErrorInfo>();

    if (errList.Find(trans) && errList.Find(desc)) {
        // do something
    }
}

public class ErrorInfo {
    public string transaction { get; set; }
    public string description { get; set; }
}

I know that the if condition is incorrect but what I want to do is search through the list and see if any node contains trans && descr, but I don't understand how to do that or if it's possible?

rene
  • 41,474
  • 78
  • 114
  • 152
Saad
  • 175
  • 1
  • 15

1 Answers1

2

You can use LINQ:

if (errList.Any(e => e.transaction == trans && e.description == descr))
{
    // do something
}
itsme86
  • 19,266
  • 4
  • 41
  • 57