Exemplo n.º 1
0
        static void Main(string[] args)
        {
            BitArray64 bitArray = new BitArray64();
            for (int i = 0; i < 64; i++)
            {
                bitArray[i] = 0;
            }
            bitArray[2] = 1;
            bitArray[36] = 1;

            Console.WriteLine("Showing the array...");
            Console.WriteLine("Using foreach:");
            foreach (var num in bitArray)
            {
                Console.Write(num);
            }
            Console.WriteLine();

            IEnumerator enumerator = bitArray.GetEnumerator();

            Console.WriteLine("Using enumerator:");
            while (enumerator.MoveNext())
            {
                Console.Write(enumerator.Current);
            }
            Console.WriteLine();
            Console.WriteLine("Value of the ulong variable in the BitArray64: {0}", bitArray.ToString());
        }
Exemplo n.º 2
0
    static void Main()
    {
        BitArray64 bits = new BitArray64();

        //set all bits at even index
        for (int i = 0; i < 64; i++)
        {
            if (i % 2 == 0)
            {
                bits[i] = 1;
            }
        }

        //clear all bits with index less than 10
        for (int i = 0; i < 10; i++)
        {
            bits[i] = 0;
        }

        IEnumerator<int> e = bits.GetEnumerator();
        e.MoveNext();
        Console.WriteLine();

        Console.WriteLine(bits);

        //foreach example
        foreach (var item in bits)
        {
            Console.WriteLine(item);
        }
    }
Exemplo n.º 3
0
    static void Main()
    {
        BitArray64 bits = new BitArray64();

        //set all bits at even index
        for (int i = 0; i < 64; i++)
        {
            if (i % 2 == 0)
            {
                bits[i] = 1;
            }
        }

        //clear all bits with index less than 10
        for (int i = 0; i < 10; i++)
        {
            bits[i] = 0;
        }

        IEnumerator <int> e = bits.GetEnumerator();

        e.MoveNext();
        Console.WriteLine();

        Console.WriteLine(bits);

        //foreach example
        foreach (var item in bits)
        {
            Console.WriteLine(item);
        }
    }
Exemplo n.º 4
0
    static void Main(string[] args)
    {
        BitArray64 bitArray = new BitArray64();

        for (int i = 0; i < 64; i++)
        {
            bitArray[i] = 0;
        }
        bitArray[2]  = 1;
        bitArray[36] = 1;

        Console.WriteLine("Showing the array...");
        Console.WriteLine("Using foreach:");
        foreach (var num in bitArray)
        {
            Console.Write(num);
        }
        Console.WriteLine();

        IEnumerator enumerator = bitArray.GetEnumerator();

        Console.WriteLine("Using enumerator:");
        while (enumerator.MoveNext())
        {
            Console.Write(enumerator.Current);
        }
        Console.WriteLine();
        Console.WriteLine("Value of the ulong variable in the BitArray64: {0}", bitArray.ToString());
    }