Thanks for that wonderful contribution of yours... Here how I implemented that.
Code:
// public method that uses LINQ Query to reorder these class's lists
public List<string> Reordering(List<string> listToReorder)
{
//LINQ used to reorder listToReorder collections
var reordered =
from item in listToReorder
orderby item descending // arrange query in descending order
select item;
List<string> newOutput = new List<string>();
// These code was commented because it didn't work
//foreach (var item in reordered)
//{
// for (int i = 0; i < reordered.Count(); i++)
// {
// newOutput[i] = item;
// }
//}
//Here's the code that worked
foreach (var item in reordered)
{
newOutput.Add(item);
}
return newOutput; // return reordered to caller as List<string> type
}
Your suggestion was this:
Code:
foreach (var item in reordered)
{
newOutput.Items.Add(item);
}
And the correction I made to your code was this:
Code:
foreach (var item in reordered)
{
newOutput.Add(item);
}
Thanks so much....
Bookmarks