private static void FullGenericCollection(int n, GenericCollection <int> genericCollection) { for (int i = 0; i < n; i++) { int element = int.Parse(Console.ReadLine()); genericCollection.AddElement(element); } }
private static void FullGenericCollection(int n, GenericCollection <string> genericCollection) { for (int i = 0; i < n; i++) { string element = Console.ReadLine(); genericCollection.AddElement(element); } }
private static void FullGenericCollection(int n, GenericCollection <Box <double> > genericCollection) { for (int i = 0; i < n; i++) { double element = double.Parse(Console.ReadLine()); Box <double> box = new Box <double>(element); genericCollection.AddElement(box); } }
static void Main(string[] args) { int count = int.Parse(Console.ReadLine()); var collection = new GenericCollection <int>(); for (int i = 0; i < count; i++) { var element = int.Parse(Console.ReadLine()); collection.AddElement(element); } string[] indexes = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); int firstIndex = int.Parse(indexes[0]); int secondIndex = int.Parse(indexes[1]); collection.SwapElements(firstIndex, secondIndex); collection.Print(); }