当前位置: 首页>>代码示例>>C#>>正文


C# BitVector32.ToString方法代码示例

本文整理汇总了C#中System.Collections.Specialized.BitVector32.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# BitVector32.ToString方法的具体用法?C# BitVector32.ToString怎么用?C# BitVector32.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.Specialized.BitVector32的用法示例。


在下文中一共展示了BitVector32.ToString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            /*
            BitVector32 answers = new BitVector32(-1);
            */
            // Creates and initializes a BitVector32 with all bit flags set to FALSE.
            BitVector32 myBV = new BitVector32(0);

            // Creates masks to isolate each of the first five bit flags.
            int myBit1 = BitVector32.CreateMask();
            int myBit2 = BitVector32.CreateMask(myBit1);
            int myBit3 = BitVector32.CreateMask(myBit2);
            int myBit4 = BitVector32.CreateMask(myBit3);
            int myBit5 = BitVector32.CreateMask(myBit4);

            // Sets the alternating bits to TRUE.
            Console.WriteLine("Setting alternating bits to TRUE:");
            Console.WriteLine("   Initial:         {0}", myBV.ToString());
            myBV[myBit1] = true;
            Console.WriteLine("   myBit1 = TRUE:   {0}", myBV.ToString());
            myBV[myBit3] = true;
            Console.WriteLine("   myBit3 = TRUE:   {0}", myBV.ToString());
            myBV[myBit5] = true;
            Console.WriteLine("   myBit5 = TRUE:   {0}", myBV.ToString());

            Console.ReadKey();
        }
开发者ID:eandbsoftware,项目名称:MCTS_70_536_AllQuestions,代码行数:27,代码来源:Program.cs

示例2: Test01

        public void Test01()
        {
            BitVector32 bv32;
            BitVector32 bv32Temp;       // extra BitVector32 - for comparison

            // [] BitVector is constructed as expected
            //-----------------------------------------------------------------

            bv32 = new BitVector32();
            if (bv32.Data != 0)
            {
                Assert.False(true, string.Format("Error, Data = {0} after default ctor", bv32.Data));
            }

            string result = bv32.ToString();
            if (result.IndexOf("BitVector32") == -1)
            {  // "BitVector32" is not a part of ToString()
                Assert.False(true, "Error: ToString() doesn't contain \"BitVector32\"");
            }

            bool item = bv32[1];
            if (item)
            {
                Assert.False(true, string.Format("Error: Item(0) returned {0} instead of {1}", item, false));
            }

            bv32Temp = new BitVector32();
            if (!bv32.Equals(bv32Temp))
            {
                Assert.False(true, string.Format("Error: two default vectors are not equal"));
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:32,代码来源:CtorTests.cs

示例3: Constructors

		public void Constructors ()
		{
			BitVector32 b = new BitVector32 (31);
			Assert.AreEqual (31, b.Data, "Data");
			Assert.IsTrue (b.Equals (b), "Equals(self)");
			Assert.IsTrue (b[31], "31");
			Assert.IsFalse (b[32], "32");
			Assert.AreEqual (b.ToString (), "BitVector32{00000000000000000000000000011111}", b.ToString ());

			BitVector32 b2 = new BitVector32 (b);
			Assert.IsTrue (b.Equals (b2), "Equals(b2)");
			Assert.AreEqual (b.GetHashCode (), b2.GetHashCode (), "GetHashCode==");

			b2[32] = true;
			Assert.IsFalse (b.Equals (b2), "Equals(b32)");
			Assert.IsFalse (b.GetHashCode () == b2.GetHashCode (), "GetHashCode!=");
		}
开发者ID:LevNNN,项目名称:mono,代码行数:17,代码来源:BitVector32Test.cs

示例4: Main

        static void Main(string[] args)
        {
            BitVector32 bv = new BitVector32(1);

            Console.WriteLine(bv.ToString() + " = " + bv.Data);

            int b1 = BitVector32.CreateMask();
            int b2 = BitVector32.CreateMask(b1);
            bv[b1] = true;
            bv[b2] = true;
            Console.WriteLine(bv.ToString() + " = " + bv.Data);

            BitVector32.Section s1 = BitVector32.CreateSection(8);
            BitVector32.Section s2 = BitVector32.CreateSection(10, s1);
            bv[s1] = 8;
            Console.WriteLine(bv.ToString() + " = " + bv.Data);
            Console.WriteLine(bv[s1]);
            bv[s2] = -10;
            Console.WriteLine(bv.ToString() + " = " + bv.Data);
            Console.WriteLine(bv[s2]);
        }
开发者ID:HotFury,项目名称:courses,代码行数:21,代码来源:Program.cs

示例5: Main

 static void Main(string[] args)
 {
     // Create a BitVector32 with all of its bit flags set to false.
     BitVector32 bv = new BitVector32(0);
     // Create masks to isolate each of the first five bit flags.
     int myBit1 = BitVector32.CreateMask();
     int myBit2 = BitVector32.CreateMask(myBit1);
     int myBit3 = BitVector32.CreateMask(myBit2);
     int myBit4 = BitVector32.CreateMask(myBit3);
     int myBit5 = BitVector32.CreateMask(myBit4);
     // Set alternating bits to true.
     bv[myBit1] = true;
     bv[myBit3] = true;
     bv[myBit5] = true;
     Console.WriteLine(bv.ToString() + " = " + bv.Data);
 }
开发者ID:HotFury,项目名称:courses,代码行数:16,代码来源:Program.cs

示例6: Main

 static void Main(string[] args)
 {
     // Create a BitVector32 with all of its bits set to 0.
     BitVector32 bv = new BitVector32(0);
     // Create sections with maximum values 6, 3, 1, and 15.
     BitVector32.Section mySect1 = BitVector32.CreateSection(6);
     BitVector32.Section mySect2 = BitVector32.CreateSection(3, mySect1);
     BitVector32.Section mySect3 = BitVector32.CreateSection(1, mySect2);
     BitVector32.Section mySect4 = BitVector32.CreateSection(15, mySect3);
     // Set each section to a value.
     bv[mySect1] = 5;
     bv[mySect2] = 3;
     bv[mySect3] = 1;
     bv[mySect4] = 9;
     Console.WriteLine(bv[mySect4]);
     Console.WriteLine(bv.ToString() + " = " + bv.Data);
 }
开发者ID:HotFury,项目名称:courses,代码行数:17,代码来源:Program.cs

示例7: Print

		private void Print (BitVector32.Section s)
		{
			Console.WriteLine (s.ToString () + " : "+ s.Mask + " : " + s.Offset);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:4,代码来源:BitVector32Test.cs

示例8: RunBitVector32Example

        private static void RunBitVector32Example()
        {
            // Creates and initializes a BitVector32 with all bit flags set to FALSE.
            BitVector32 myBV = new BitVector32(0);

            // Creates masks to isolate each of the first five bit flags. 
            int myBit1 = BitVector32.CreateMask();
            int myBit2 = BitVector32.CreateMask(myBit1);
            int myBit3 = BitVector32.CreateMask(myBit2);
            int myBit4 = BitVector32.CreateMask(myBit3);
            int myBit5 = BitVector32.CreateMask(myBit4);

            Console.WriteLine("Mask Values: myBit1: {0}, myBit2: {1}, myBit3: {2}, myBit4: {3}, myBit5: {4}", myBit1, myBit2, myBit3, myBit4, myBit5);

            // Sets the alternating bits to TRUE.
            Console.WriteLine("Setting alternating bits to TRUE:");
            Console.WriteLine("   Initial:         {0}", myBV.ToString());
            myBV[myBit1] = true;
            Console.WriteLine("   myBit1 = TRUE:   {0}", myBV.ToString());
            myBV[myBit3] = true;
            Console.WriteLine("   myBit3 = TRUE:   {0}", myBV.ToString());
            myBV[myBit5] = true;
            Console.WriteLine("   myBit5 = TRUE:   {0}", myBV.ToString());

            // Creates and initializes a BitVector32.
            myBV = new BitVector32(0);

            // Creates four sections in the BitVector32 with maximum values 6, 3, 1, and 15. 
            // mySect3, which uses exactly one bit, can also be used as a bit flag.
            BitVector32.Section mySect1 = BitVector32.CreateSection(6);
            BitVector32.Section mySect2 = BitVector32.CreateSection(3, mySect1);
            BitVector32.Section mySect3 = BitVector32.CreateSection(1, mySect2);
            BitVector32.Section mySect4 = BitVector32.CreateSection(15, mySect3);

            // Displays the values of the sections.
            Console.WriteLine("Initial values:");
            Console.WriteLine("\tmySect1: {0}", myBV[mySect1]);
            Console.WriteLine("\tmySect2: {0}", myBV[mySect2]);
            Console.WriteLine("\tmySect3: {0}", myBV[mySect3]);
            Console.WriteLine("\tmySect4: {0}", myBV[mySect4]);

            // Sets each section to a new value and displays the value of the BitVector32 at each step.
            Console.WriteLine("Changing the values of each section:");
            Console.WriteLine("\tInitial:    \t{0}", myBV.ToString());
            myBV[mySect1] = 5;
            Console.WriteLine("\tmySect1 = 5:\t{0}", myBV.ToString());
            myBV[mySect2] = 3;
            Console.WriteLine("\tmySect2 = 3:\t{0}", myBV.ToString());
            myBV[mySect3] = 1;
            Console.WriteLine("\tmySect3 = 1:\t{0}", myBV.ToString());
            myBV[mySect4] = 9;
            Console.WriteLine("\tmySect4 = 9:\t{0}", myBV.ToString());

            // Displays the values of the sections.
            Console.WriteLine("New values:");
            Console.WriteLine("\tmySect1: {0}", myBV[mySect1]);
            Console.WriteLine("\tmySect2: {0}", myBV[mySect2]);
            Console.WriteLine("\tmySect3: {0}", myBV[mySect3]);
            Console.WriteLine("\tmySect4: {0}", myBV[mySect4]);
        }
开发者ID:oblivious,项目名称:Oblivious,代码行数:60,代码来源:Program.cs

示例9: Main

        static void Main(string[] args)
        {
            System.Collections.ArrayList al;
            System.Collections.BitArray ba;
            System.Collections.Hashtable ht;
            System.Collections.Queue q;
            System.Collections.SortedList sl;
            System.Collections.Stack s;

            System.Collections.Specialized.BitVector32 bv;
            System.Collections.Specialized.HybridDictionary hd;
            System.Collections.Specialized.ListDictionary ld; // Uses a singly linked list which is why it's only good for a few items.
            System.Collections.Specialized.NameValueCollection nvc;
            System.Collections.Specialized.OrderedDictionary od;
            System.Collections.Specialized.StringCollection sc;
            System.Collections.Specialized.StringDictionary sd;

            al = new ArrayList();
            ba = new BitArray(32);
            ht = new Hashtable();
            q = new Queue();
            sl = new SortedList();
            s = new Stack();
            
            //BitVector32... so much fun to be had.
            //RunBitVector32Example();
            
            bool item;
            int trues;
            DateTime start, end;
            start = DateTime.Now;
            item = false;
            trues = 0;
            ba = new BitArray(20);
            for (int i = 0; i < 20; i += 2)
            {
                ba.Set(i, true);
            }
            Console.Write("BitArray {");
            for (int i = 0; i < 20; i++ )
                Console.Write(ba.Get(i) ? "1" : "0");
            Console.WriteLine("}");

            for (int j = 0; j < 1000000; j++)
            {
                for (int i = 0; i < 20; i++)
                {
                    item = ba.Get(i);
                    if (item)
                        trues++;
                }
            }
            end = DateTime.Now;
            Console.WriteLine("{0} trues values were counted...", trues);
            Console.WriteLine("BitArray took: {0}ms", (end - start).TotalMilliseconds.ToString("0.00"));

            bv = new BitVector32();
            start = DateTime.Now;
            item = false;
            trues = 0;
            int l = 1;
            for (int i = 0; i < 10; i++)
            {
                bv[l] = true;
                l *= 4;
            }
            Console.WriteLine(Math.Pow(2, 2));
            Console.WriteLine(bv.ToString());
            for (int j = 0; j < 1000000; j++)
            {
                int k = 1;
                for (int i = 0; i < 20; i++)
                {
                    item = bv[k];
                    k *= 2;
                    if (item)
                        trues++;
                }
            }
            end = DateTime.Now;
            Console.WriteLine("{0} trues values were counted...", trues);
            Console.WriteLine("BitVector32 took: {0}ms", (end - start).TotalMilliseconds.ToString("0.00"));
        }
开发者ID:oblivious,项目名称:Oblivious,代码行数:83,代码来源:Program.cs

示例10: Test01

        public void Test01()
        {
            BitVector32 bv32;
            BitVector32 bv32_1;       // extra BitVector32 - for comparison
            string str = "";              // result of ToString() for bv32
            string str_1 = "";                    // result of ToString() for bv32_1
            int data = 0;

            // [] two BitVectors that are the same should return the same string
            //-----------------------------------------------------------------

            bv32 = new BitVector32();
            bv32_1 = new BitVector32();
            str = bv32.ToString();
            str_1 = bv32_1.ToString();
            if (String.Compare(str, str_1) != 0)
            {
                Assert.False(true, string.Format("Error, ToString() of two default structs: \"{0}\" != \"{1}\"", str, str_1));
            }


            // generate random data value
            DateTime time = DateTime.Now;
            data = -55;
            System.Random random = new System.Random(data);
            data = random.Next(System.Int32.MinValue, System.Int32.MaxValue);

            bv32 = new BitVector32(data);
            bv32_1 = new BitVector32(data);
            str = bv32.ToString();
            str_1 = bv32_1.ToString();
            if (String.Compare(str, str_1) != 0)
            {
                Assert.False(true, string.Format("Error, ToString() of two equal vectors: \"{0}\" != \"{1}\"", str, str_1));
            }

            bv32 = new BitVector32(data);
            if (data < Int32.MaxValue)
                data++;
            else
                data--;
            bv32_1 = new BitVector32(data);
            str = bv32.ToString();
            str_1 = bv32_1.ToString();
            if (String.Compare(str, str_1) == 0)
            {
                Assert.False(true, string.Format("Error, ToString() of two different vectors: \"{0}\" == \"{1}\"", str, str_1));
            }

            bv32 = new BitVector32();
            str = bv32.ToString();
            str_1 = bv32.ToString();
            if (String.Compare(str, str_1) != 0)
            {
                Assert.False(true, string.Format("Error, ToString() of the same default struct: \"{0}\" != \"{1}\"", str, str_1));
            }

            bv32 = new BitVector32(data);
            str = bv32.ToString();
            str_1 = bv32.ToString();
            if (String.Compare(str, str_1) != 0)
            {
                Assert.False(true, string.Format("Error, ToString() of the same vector: \"{0}\" != \"{1}\"", str, str_1));
            }

            data = 0;
            bv32 = new BitVector32(data);
            bv32_1 = new BitVector32(data);
            str = bv32.ToString();
            str_1 = bv32_1.ToString();
            if (String.Compare(str, str_1) != 0)
            {
                Assert.False(true, string.Format("Error, ToString() of two {2}-vectors: \"{0}\" != \"{1}\"", str, str_1, data));
            }

            data = 1;
            bv32 = new BitVector32(data);
            bv32_1 = new BitVector32(data);
            str = bv32.ToString();
            str_1 = bv32_1.ToString();
            if (String.Compare(str, str_1) != 0)
            {
                Assert.False(true, string.Format("Error, ToString() of two {2}-vectors: \"{0}\" != \"{1}\"", str, str_1, data));
            }

            data = -1;
            bv32 = new BitVector32(data);
            bv32_1 = new BitVector32(data);
            str = bv32.ToString();
            str_1 = bv32_1.ToString();
            if (String.Compare(str, str_1) != 0)
            {
                Assert.False(true, string.Format("Error, ToString() of two {2}-vectors: \"{0}\" != \"{1}\"", str, str_1, data));
            }

            data = Int32.MaxValue;
            bv32 = new BitVector32(data);
            bv32_1 = new BitVector32(data);
            str = bv32.ToString();
            str_1 = bv32_1.ToString();
//.........这里部分代码省略.........
开发者ID:noahfalk,项目名称:corefx,代码行数:101,代码来源:ToStringTests.cs


注:本文中的System.Collections.Specialized.BitVector32.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。