I have an extensions array and I have to find out whether all the elements in the array has the same value or different values using lambda expressions. I have written the below code and its always returning me true. In the following extensions array, it should return me false as the .bmp is different extensions than others. Could you help me to achieve the task?
string[] extensions = { ".doc", ".doc", ".bmp" };
var result = extensions.All(x => extensions.Contains(x));
.Distinct()and check the length. If it is 1, all are the same, and if it is >1, you have different values.