Is there a way to use LINQ to get a separate list of elements from a list of an array of objects without knowing how many elements exist in each array? The number of elements in each element of the array will be the same throughout the list.
var foo = new List<object[]>();
foo.Add(new object[] { 1, "Something", true });
foo.Add(new object[] { 1, "Some Other", false });
foo.Add(new object[] { 2, "Something", false });
foo.Add(new object[] { 2, "Something", false });
List<object[]> bar = foo.Select(x => new { X1 = x[0], X2 = x[1], X3 = x[2] })
.Distinct()
.Select(x => new object[] { x.X1, x.X2, x.X3 })
.ToList();
List<object[]> bar = ??
I know how many elements are there at runtime, if that helps?
If this is not possible in LINQ, can someone suggest a method that I could use to achieve the desired results?
source
share