I'am using an Integer list. Before adding an element 'x', I need to check if 'x' exists in the list. how can this be implemented
You can use List.Contains Method
myList.Contains(x)
OR
myList.Any(p => p == x)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With