Link to home
Start Free TrialLog in
Avatar of Tagyourareit
Tagyourareit

asked on

c# additg items to current list

Hello,

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; }            
			
		}
		

Open in new window


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
Avatar of chaau
chaau
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial