How to check if the list contains the value

List(4) { “{\r\n “number”: “PR1”,\r\n “state”: “New”\r\n}”, “{\r\n “number”: “PR9”,\r\n “state”: “Closed”\r\n}”, “{\r\n “number”: “PR2”,\r\n “state”: “New”\r\n}”, “{\r\n “number”: “PR3”,\r\n “state”: “New”\r\n}” }

Above is the output which I am getting, I need to get only state which is closed
can anyone help me

Give a try on:
YourListVar.Any(Function (x) x.Contains("""state"": ""Closed"""))
it returns true or false if the List contains “state”:“Closed”

filtering to the item(s) containing the state=Closed can be done as following:
YourListVar.Where(Function (x) x.Contains("""state"": ""Closed""")).toList

it retuns a list of strings, with the items containing: “state”:“Closed”
the returned list is empty list if it is not found

2 Likes