Not sure if this is possible somehow, without doing a full comparison between each of the N variables.
for int or float, I can use simple math, to figure out if the numbers are the same; doing the sum, and dividing by the number of elements.
But if I want to check if 3 variables contain the same string, I can't use this approach. It may be possible that either var1 and var2 are the same, or that var3 and var 1 are the same, and also that var2 and var3 may be the same. From what I understand, unless you make a comparison among EACH variable, there is no way to know if the content of that variable is the same.
Did I miss something or there is an easier way?
Example with 3 variables:
string var1 = "hello";
string var2 = "there";
string var3 = "hello";
if (var1 == var2 || var1 == var3 || var2 == var3)
//got a duplicate
else
//all are different
Imagine to compare 20 variables, it takes forever to write a comparison statement.
To me it sound similar to a search algorithm, could I apply the same concept that I may apply to a sorted binary search?