當前位置: 首頁>>代碼示例>>C#>>正文


C# Int32.CopyTo方法代碼示例

本文整理匯總了C#中System.Int32.CopyTo方法的典型用法代碼示例。如果您正苦於以下問題:C# Int32.CopyTo方法的具體用法?C# Int32.CopyTo怎麽用?C# Int32.CopyTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Int32的用法示例。


在下文中一共展示了Int32.CopyTo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

        static void Main(string[] args)
        {
            Transaction t1 = new Transaction("001", "8/10/2012", 78900.00);
            Transaction t2 = new Transaction("002", "9/10/2012", 451900.00);
            t1.showTransaction();
            t2.showTransaction();
            Console.ReadKey();

            Int32[] arrInt = new Int32[] { 7, 6, 9, 65, 8, 3, 5, 4 };

            Int32[] arrIntCopy = new Int32[arrInt.Length];
            //arrInt.CopyTo(arrIntCopy, 0);
            ArraySelection<Int32> arrIntSel = new ArraySelection<Int32>();
            arrInt.CopyTo(arrIntCopy, 0);
            arrIntSel.ElementsCollection = arrIntCopy;
            arrIntSel.Sort();
            Console.Write("array selection sort:\n");
            for (int i = 0; i < arrIntSel.ElementsCollection.Length; ++i)
            {
                Console.Write("{0} ", arrIntSel.ElementsCollection.GetValue(i).ToString());
            }
            Console.WriteLine();
            Console.ReadKey();

            ArrayInsert<Int32> arrIntIns = new ArrayInsert<Int32>();
            arrInt.CopyTo(arrIntCopy, 0);
            arrIntIns.ElementsCollection = arrIntCopy;
            arrIntIns.Sort();
            Console.Write("array Insert sort:\n");
            for (int i = 0; i < arrIntIns.ElementsCollection.Length; ++i)
            {
                Console.Write("{0} ", arrIntIns.ElementsCollection.GetValue(i).ToString());
            }
            Console.WriteLine();
            Console.ReadKey();

            ArrayBubble<Int32> arrIntBub = new ArrayBubble<Int32>();
            arrInt.CopyTo(arrIntCopy, 0);
            arrIntBub.ElementsCollection = arrIntCopy;
            arrIntBub.Sort();
            Console.Write("array Buble sort:\n");
            for (int i = 0; i < arrIntBub.ElementsCollection.Length; ++i)
            {
                Console.Write("{0} ", arrIntBub.ElementsCollection.GetValue(i).ToString());
            }
            Console.WriteLine();
            Console.ReadKey();

            ArrayShell<Int32> arrIntShe = new ArrayShell<Int32>();
            arrInt.CopyTo(arrIntCopy, 0);
            arrIntShe.ElementsCollection = arrIntCopy;
            arrIntShe.Sort();
            Console.Write("array Shell sort:\n");
            for (int i = 0; i < arrIntShe.ElementsCollection.Length; ++i)
            {
                Console.Write("{0} ", arrIntShe.ElementsCollection.GetValue(i).ToString());
            }
            Console.WriteLine();
            Console.ReadKey();

            ArrayMerge<Int32> arrIntMer = new ArrayMerge<Int32>();
            arrInt.CopyTo(arrIntCopy, 0);
            arrIntMer.ElementsCollection = arrIntCopy;
            arrIntMer.Sort();
            Console.Write("array Merge sort:\n");
            for (int i = 0; i < arrIntMer.ElementsCollection.Length; ++i)
            {
                Console.Write("{0} ", arrIntMer.ElementsCollection.GetValue(i).ToString());
            }
            Console.WriteLine();
            Console.ReadKey();

            ArrayQuick<Int32> arrIntQui = new ArrayQuick<Int32>();
            arrInt.CopyTo(arrIntCopy, 0);
            arrIntQui.ElementsCollection = arrIntCopy;
            arrIntQui.Sort();
            Console.Write("array Quick sort:\n");
            for (int i = 0; i < arrIntQui.ElementsCollection.Length; ++i)
            {
                Console.Write("{0} ", arrIntQui.ElementsCollection.GetValue(i).ToString());
            }
            Console.WriteLine();
            Console.ReadKey();

            ArrayHeap<Int32> arrIntHea = new ArrayHeap<Int32>();
            arrInt.CopyTo(arrIntCopy, 0);
            arrIntHea.ElementsCollection = arrIntCopy;
            arrIntHea.Sort();
            Console.Write("array Heap sort:\n");
            for (int i = 0; i < arrIntHea.ElementsCollection.Length; ++i)
            {
                Console.Write("{0} ", arrIntHea.ElementsCollection.GetValue(i).ToString());
            }
            Console.WriteLine();
            Console.ReadKey();
        }
開發者ID:CockDeveloper,項目名稱:Alogrithms_Sort_Search,代碼行數:96,代碼來源:Hello.cs


注:本文中的System.Int32.CopyTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。