Esempio n. 1
0
 static void DeleteFromList(ref List <int> list, int index)
 {
     if (ListMethods.CorrectIndex(list, index - 1))
     {
         list.RemoveRange(0, index);
     }
 }
Esempio n. 2
0
 static void TakeFromTheList(ref List <int> list, int index)
 {
     if (ListMethods.CorrectIndex(list, index))
     {
         list.RemoveRange(index, list.Count - index);
     }
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            // recieve List<int> from console
            ListMethods.ReceiveIntList(out List <int> list, new[] { " " });


            // [0] - number of elements to take from the list (starting from the first one)
            // [1] - number of elements to delete from list (starting from the first one)
            // [2] - number searched in collection
            int[] numbers = Console.ReadLine()
                            .Split(' ')
                            .Where(p => !string.IsNullOrEmpty(p))
                            .Select(p => int.Parse(p))
                            .ToArray();


            TakeFromTheList(ref list, numbers[0]);

            DeleteFromList(ref list, numbers[1]);

            SearchInListForNumber(ref list, numbers[2]);
        }