Home > database >  Equals() function with multiple values instead of one
Equals() function with multiple values instead of one

Time:09-29

I have been using the following since a few years:

Dim mycol = xml.First(Function(x) CStr(x.Attribute("name")).Equals("Source"))

Now I would like to retrieve if either the name attribute is equal to "Source" or "Input".

Does any solution exist for this case?

I have tried the following without any success

Dim cases As String() = {"Source", "Input"}
Dim mycol = xml.First(Function(x) CStr(x.Attribute("name")).Equals(cases))

CodePudding user response:

You would reverse the order of the comparison and use Contains:

Dim mycol = xml.First(Function(x) cases.Contains(CStr(x.Attribute("name"))))
  • Related