private static void RemoveElement(List <int> lst) { Console.WriteLine(); PrintLst(lst); if (lst.Count == 0) { Console.WriteLine("Saraksts ir tukss!"); return; } try { Console.WriteLine("Kuru elementu velaties dzest?"); int toDelete = Convert.ToInt32(Console.ReadLine()); lst.RemoveAt(toDelete); FileOperations.Write(lst); } catch { Console.WriteLine("Kludaina ievade!"); } Console.WriteLine(); }
private static void AddElement(List <string> lst) { Console.WriteLine(); Console.WriteLine("Ievadiet elementu!"); lst.Add(Console.ReadLine()); FileOperations.Write(lst); Console.WriteLine(); }
private static void AddElement(List <int> lst) { Console.WriteLine(); Console.WriteLine("Ievadiet elementu!"); try { lst.Add(Convert.ToInt32(Console.ReadLine())); FileOperations.Write(lst); Console.WriteLine(); } catch { Console.WriteLine("Ievadīto elemntu nevar pārkonvertēt uz Int"); AddElement(lst); } }