I have to make a program that takes the domain for each columns.
My code is this, but when i want show throws an exception (System.ArgumentOutOfRangeException).
string[] all_lines = { "1, 2, 3" , "4, 5, 6", "4, 2, 3", "4, 2, 6", "9, 8, 7" };
string[] separator = new string[] { ", " };
int nAtt = all_lines[0].Split(separator, StringSplitOptions.RemoveEmptyEntries).Count() ;
List<IEnumerable> dom = new List<IEnumerable>();
for (int i = 0; i < nAtt; i++)
{
var ele = (from lines in all_lines
let data = lines.Split(separator, StringSplitOptions.RemoveEmptyEntries)
select data.ElementAt(i)).Distinct();
dom.Add(ele);
}
foreach (var row in dom)
{
Console.Write("( ");
foreach (var ele in row)
Console.Write("{0} ", ele);
Console.WriteLine(")");
}
The output of this code should be:
( 1 4 9 )
( 2 5 8 )
( 3 6 7 )
Is there any solution or alternative for this?