hello,
i had a List and i had to check if it contain only a values for ex “Hello”
hello,
i had a List and i had to check if it contain only a values for ex “Hello”
Check the length of list.
If LstStr.Length>1
You can check it like this
listVar.Count > 1
i mean by one value: checking that there is for exemple onlmy the string “CHEQUE” in the list
if myList.Count = 1 And myList(0) = “CHEQUE”
i did not think it works:
i think of using ```
someList.Except(desiredItems).Any()
desired item must be enumerable, but i had to check on string
Can you elaborate why the previous suggestion did not work? What type of list do you have?
.Except essentially compares two collections and removes equal values. Don’t think this is the optimal solution for your use case.
so let’s resume:
i had a list:
List1 ={“CHEQUE”,“blabla”, “CHEQUE”,“blabla”}
how to insure if all the values = CHEQUE
Ok now I see. Then you can check with .Except:
if List1.Except({“CHEQUE”}).Count > 0 // if the returning count is more than 0 you have something else than CHEQUE in the list.