static void Main(string[] args) { System.Collections.Stack stack = new Stack(); Show.Coleccion coleccion = new Show.Coleccion(); // Agragar Objetos stack.Push("Manzana"); stack.Push("Pera"); stack.Push("Ciruela"); stack.Push("Mango"); // Iteramos coleccion.Show(stack, ""); // Hacemos pop Console.WriteLine(stack.Pop()); coleccion.Show(stack, ""); // Hacemos Console.WriteLine(stack.Peek()); coleccion.Show(stack, ""); // Cantida de elementos Show.CountElement.Count(stack); Console.ReadKey(); }
// https://youtu.be/3VsCtkfQMPI static void Main(string[] args) { System.Collections.SortedList sortedList = new SortedList(); // Agregamos datos sortedList.Add(754, "Honda"); sortedList.Add(123, "Volvo"); sortedList.Add(587, "Nissan"); sortedList.Add(323, "Fiat"); // Show.Coleccion show = new Show.Coleccion(); // Iteramos show.Show(sortedList); // Cantidad de elementos Show.CountElement.Count(sortedList); // Contiene elementos Console.WriteLine(sortedList.Contains(123)); Console.WriteLine(sortedList.Contains(678)); Console.WriteLine(sortedList.ContainsKey(587)); Console.WriteLine(sortedList.ContainsValue("Volvo")); Console.WriteLine("----------"); //// Obtenemos elemento por indice Console.WriteLine(sortedList.GetKey(2)); Console.WriteLine(sortedList.GetByIndex(2)); Console.ReadKey(); }
static void Main(string[] args) { SortedSet <Show.Punto> puntos = new SortedSet <Show.Punto> { new Show.Punto(3, 7), new Show.Punto(8, 11), new Show.Punto(2, 6), }; puntos.Add(new Show.Punto(5, 9)); Show.Coleccion coleccion = new Show.Coleccion(); coleccion.Show(puntos); puntos.Add(new Show.Punto(1, 15)); puntos.Add(new Show.Punto(1, 12)); coleccion.Show(puntos); Console.ReadKey(); }
static void Main(string[] args) { System.Collections.Generic.List <Int16> Lista = new System.Collections.Generic.List <short> { 7, 5, 4, 3, 8 }; // Desde que iniciamos Lista.Add(9); // Anadiendo nuevos datos Show.Coleccion coleccion = new Show.Coleccion(); coleccion.Show(Lista); Show.CountElement.Count(Lista); // Vemos sin contiene a determinado Elemento Console.WriteLine(Lista.Contains(5)); Console.WriteLine("-------------"); // Obtenemos indice de un elemento Console.WriteLine(Lista.IndexOf(4)); Console.WriteLine("-------------"); // Insertamos elementos en un indice Lista.Insert(2, 55); Console.WriteLine("-------------"); foreach (int valor in Lista) { Console.WriteLine(valor);// Coleccion.Show(Lista); } Console.WriteLine("-------------"); // Eliminamos elementos en un indice Lista.RemoveAt(2); Console.WriteLine("-------------"); coleccion.Show(Lista); // Eliminar por valor Lista.Remove(8);// Elimina el primero que se encuentre coleccion.Show(Lista); // Lista se coloca en sentido contrario Lista.Reverse(); coleccion.Show(Lista); // Mandamos a ordenar la Lista Lista.Sort(); coleccion.Show(Lista); // Creamos nuna lista para Clase // https://youtu.be/49ls_biDRog System.Collections.Generic.List <Show.Punto> ListPuntos = new System.Collections.Generic.List <Show.Punto> { new Show.Punto(5, 7), new Show.Punto(7, 8) // Modo simplificado }; ListPuntos.Add(new Show.Punto(12, 5)); // Modo posterior foreach (Show.Punto punto in ListPuntos) { Console.WriteLine(punto); } // No funciona por que no hemos implementado Icomparable // ListPuntos.Sort(); Console.ReadKey(); }