F
fTob98
Guest
List<List<int>> list0 = new List<List<int>>();
foreach (var x in Field)
{
list0.Clear();
foreach (var y in SeriesSet)
{
if (y.Contains(x)) list0.Add;
}
FSeries.Add(list0);
}
I have List<List<int>> SeriesSet and List<int> Field. My goal is to create collection (List<List<List<int>>> FSeries) that for each element x in Field holds series y from SeriesSet that each y contains x e.g.
Field = {0,1,2}
SeriesSet = {{0,1},{0,2},{1,2}}
FSeries = {{{0,1},{0,2}},{{0,1},{1,2}},{{0,2},{1,2}}}
Unfortunately, after each iteration of the first foreach loop FSeries is filled with same values for each element that has already been asigned e.g. FSeries[0] was {{0,1},{0,2}} and after second iteration FSeries[0] = {{0,1},{1,2}} and FSeries[1] = {{0,1},{1,2}}. What is wrong in my code? I thought that it would append the list to the end of FSeries and produce FSeries[0]={{0,1},{0,2}} and FSeries[1]={{0,1},{1,2}}
Continue reading...
foreach (var x in Field)
{
list0.Clear();
foreach (var y in SeriesSet)
{
if (y.Contains(x)) list0.Add;
}
FSeries.Add(list0);
}
I have List<List<int>> SeriesSet and List<int> Field. My goal is to create collection (List<List<List<int>>> FSeries) that for each element x in Field holds series y from SeriesSet that each y contains x e.g.
Field = {0,1,2}
SeriesSet = {{0,1},{0,2},{1,2}}
FSeries = {{{0,1},{0,2}},{{0,1},{1,2}},{{0,2},{1,2}}}
Unfortunately, after each iteration of the first foreach loop FSeries is filled with same values for each element that has already been asigned e.g. FSeries[0] was {{0,1},{0,2}} and after second iteration FSeries[0] = {{0,1},{1,2}} and FSeries[1] = {{0,1},{1,2}}. What is wrong in my code? I thought that it would append the list to the end of FSeries and produce FSeries[0]={{0,1},{0,2}} and FSeries[1]={{0,1},{1,2}}
Continue reading...