+ 1
How to compare multiple variables in c#?
3 Answers
+ 2
the simplest way is to compare it using AND &&
for example you can do this:
if (a == b && a == c && b == c) {
//insert code here
}
However if you have many variables, you could build an array and use the IEnumerable. This code verifies if all values are equal to a variable foo
if(new[] { a, b, c, d, e, f, g, h, i, j }.All(x => x == foo));
+ 1
thankx bro
0
Mete todas las variables en un array y has las comparaciones con un for