Hakan Axheim

Hakan Axheim

  • NA
  • 201
  • 33k

How to check a List for values

Jan 22 2021 9:32 PM
Hi,
 
I have a List values = new List();
 
values.add("0");This 
values.add("1");
values.add("9)";
 
Only values 0 and 9 are valid so therefore I must check if the list above has values that are different from the values 0 and 9. I need help with that from someone that is experienced in C#.
 
I have tried with this;
 
This if statement will always be true because I only check for 0 and 9.
if (values.ContainshT("0") && values.Contains("9"))
This if statement will also be true because there is an item that is different from 0 and 9.
if (!values.ContainshT("0") && !values.Contains("9"))
 How to check if items exist other than 0 and 9 it is false and if only items 0 and 9 exist then it is true. 

Answers (3)