Why changes to the outer data-source is not reflected, while they show-up
for the inner data-source?
Why changes to the outer data-source is not reflected, while they show-up
for the inner data-source?? Pls help
public static void MyMethod(char[] inputDS1, char[] inputDS2)
{
Console.WriteLine("\n'from' clause - Display all possible
combinations of a-b-c-d.");
//query syntax
IEnumerable<ChrPair> resultset = from res1 in inputDS1
from res2 in inputDS2
select new ChrPair(res1, res2);
//Write result-set
Console.WriteLine("\n\nOutput list -->");
displayList(resultset);
//swap positions
//obs: changes to the first ds is not reflected in the resultset.
char[] temp = inputDS1;
inputDS1 = inputDS2;
inputDS2 = temp;
//run query again
displayList(resultset);
Console.WriteLine("\n------------------------------------------");
}
Input:
('a','b'), ('c','d')
Output:
ac, ad, bc, bd, **aa. ab, ba, bb**
I expected all possible combinations (ac, ad, bc, bd, ca, cb, da, db) as I
swapped the Data-sources before the second Write. When I do a ToList()
before the second Write, I get the expected result, so is it because that
Select is lazy? Please explain.
No comments:
Post a Comment