Example #1
0
        static void Main(string[] args)
        {
            // Colecciones adentro de System.Collection
            // ArrayList
            // BitArray
            // Hashtable (k,v)
            // Queue
            // SortedList (k,v) k,v
            // Stack
            int       r    = 0;
            Coleccion show = new Coleccion();

            #region https://youtu.be/GAal3fPN59g
            System.Collections.ArrayList Palabras =
                new System.Collections.ArrayList();

            // Podemos adiccionar con rango
            Palabras.AddRange(new System.String[] {
                "Hola", "como", "estas?"
            });

            CountElement.Count(Palabras);

            // Recorremos el Array con loop for
            show.Show(Palabras, 2);

            // Agragar mas palabra
            Palabras.Add("Bien y tu?");
            // Volvemos a mostrar el total de elementos
            CountElement.Count(Palabras);

            //Recorriendo con foreach
            show.ShowForeach(Palabras, 2);

            #endregion

            #region https://youtu.be/bdGSQ-9N22s
            // Array con valores numericos
            System.Collections.ArrayList Valores =
                new System.Collections.ArrayList();

            Valores.AddRange(new int[] { 5, 6 });
            Valores.Add(7);
            Valores.Add(8);

            ////
            CountElement.Count(Valores);
            ////

            // Recorremos con loop for
            show.Show(Valores, 1, r);


            // Verificar si existe un elemento en el ArrayList
            //con el metodo Contains()
            System.Console.WriteLine(" 5 existe " + Valores.Contains(5));
            System.Console.WriteLine(" 1 existe {0}", Valores.Contains(1));
            System.Console.Write("--------\n");

            // Insertamos en un indice en particular
            Valores.Insert(2, 4);

            ////
            CountElement.Count(Valores);
            ////

            show.ShowForeach(Valores, 2);

            // Remover un elemento
            Valores.Remove(4);
            CountElement.Count(Valores);
            show.Show(Valores, 1, r);

            // Remover en una posicion
            Valores.RemoveAt(0);
            CountElement.Count(Valores);
            show.Show(Valores, 1, r);
            #endregion
            System.Console.ReadKey();
        }
Example #2
0
        static void Main(string[] args)
        {
            #region https://youtu.be/_UtKEYYhi24
            Coleccion show = new Coleccion();
            System.Collections.BitArray bitArray =
                new System.Collections.BitArray(
                    new byte[] { 1, 2, 4, 8, 16 });// Convertiendo byte a bit

            CountElement.Count(bitArray);
            Coleccion.Show(bitArray, 2);

            //// Obtenemos un bit en particular
            System.Console.WriteLine(bitArray.Get(3));

            //// ponemos un bit en particular
            bitArray.Set(3, true);
            System.Console.WriteLine(bitArray.Get(3));
            Coleccion.Show(bitArray, 2);


            //https://youtu.be/pGS78ttnqfY

            // Clonacion del BitArray
            System.Collections.BitArray bitArray2 =
                (System.Collections.BitArray)bitArray.Clone();

            //// Invertir el Array, NOT
            bitArray2.Not();
            Coleccion.Show(bitArray2, 2);

            // Creando otro Array
            System.Collections.BitArray bitArray3 =
                new System.Collections.BitArray(new byte[] { 5, 7, 9, 13, 15 });
            Coleccion.Show(bitArray3, 2, "3°Array");

            //// Hacemos Or entre Arreglos
            bitArray3.Or(bitArray); // El resultado se guarda en el Array que llevo
                                    //acabo la invocacion.
            Coleccion.Show(bitArray, pNombre: "1°Array");
            Coleccion.Show(bitArray3, 3, pNombre: "Result");
            System.Console.WriteLine("=|||||||||=");

            //// Hacemos AND entre Array
            Coleccion.Show(bitArray, pNombre: "1°Array");
            Coleccion.Show(bitArray3, pNombre: "3°Array");

            // Hacemos el AND, BitArray 3 se modifica con el resultado
            bitArray3.And(bitArray);
            Coleccion.Show(bitArray3, 3, "Result");
            System.Console.WriteLine("=&&&&&&&&&&&=");

            //// Hamos XOR entre Array
            bitArray3 =
                new System.Collections.BitArray(new byte[] { 5, 7, 9, 13, 21 });
            Coleccion.Show(bitArray, pNombre: "1°Array");
            Coleccion.Show(bitArray3, pNombre: "3°Array");

            // Hacemos el XOR, Array 3 se modifica con el resultado
            bitArray3.Xor(bitArray);
            Coleccion.Show(bitArray3, pNombre: "Result");

            System.Console.ReadKey();
            #endregion
        }