Tagyourareit
asked on
c# additg items to current list
Hello,
I have folowing code:
Problem is my code is overriding list at every call to HandleInfo. So element count is always 1.
What i want is add items to list instead of creating new one each time function is called.
thank you
I have folowing code:
public static void HandleInfo()
{
List<Info> list = new List<Info>();
try
{
switch (name)
{
case "INFOS":
InfoList(list);
break;
}
}
public static List<Info> InfoList(List<Info> list)
{
list.Add(new Info() { ID = _ID });
List<Info> SortedList = list.OrderBy(o => o.ID).ToList();
var firstItem = SortedList.ElementAt(0);
return SortedList;
}
public class Info
{
public long UID { get; set; }
}
Problem is my code is overriding list at every call to HandleInfo. So element count is always 1.
What i want is add items to list instead of creating new one each time function is called.
thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.