Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // 测试 int 类型的.
            RandomOrder <int> intRandom = new RandomOrder <int>();

            List <int> intList = new List <int>()
            {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };

            List <int> intRandomList = intRandom.DoRandomOrder(intList);

            Console.WriteLine("Int 数据列表随机排序.");
            for (int i = 0; i < intRandomList.Count; i++)
            {
                Console.Write("{0}  ", intRandomList[i]);
            }
            Console.WriteLine();



            // 测试 string 类型的.
            RandomOrder <string> stringRandom = new RandomOrder <string>();

            List <string> stringList = new List <string>()
            {
                "A", "B", "C", "D", "E", "F", "G",
            };

            List <string> stringRandomList = stringRandom.DoRandomOrder(stringList);

            Console.WriteLine("string 数据列表随机排序.");
            for (int i = 0; i < stringRandomList.Count; i++)
            {
                Console.Write("{0}  ", stringRandomList[i]);
            }
            Console.WriteLine();



            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // 测试 int 类型的.
            RandomOrder<int> intRandom = new RandomOrder<int>();

            List<int> intList = new List<int>()
            {
                1,2,3,4,5,6,7,8,9,10
            };

            List<int> intRandomList = intRandom.DoRandomOrder(intList);
            Console.WriteLine("Int 数据列表随机排序.");
            for (int i = 0; i < intRandomList.Count; i++)
            {
                Console.Write("{0}  ", intRandomList[i]);
            }
            Console.WriteLine();



            // 测试 string 类型的.
            RandomOrder<string> stringRandom = new RandomOrder<string>();

            List<string> stringList = new List<string>()
            {
                "A", "B", "C", "D", "E", "F", "G",
            };

            List<string> stringRandomList = stringRandom.DoRandomOrder(stringList);
            Console.WriteLine("string 数据列表随机排序.");
            for (int i = 0; i < stringRandomList.Count; i++)
            {
                Console.Write("{0}  ", stringRandomList[i]);
            }
            Console.WriteLine();



            Console.ReadLine();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 测试 泛型的类. (类与方法都是泛型)
        /// </summary>
        static void TestGenericClass()
        {
            Console.WriteLine("测试 泛型的类. (类与方法都是泛型)");

            // 测试 int 类型的.
            RandomOrder <int> intRandom = new RandomOrder <int>();

            List <int> intList = new List <int>()
            {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };

            List <int> intRandomList = intRandom.DoRandomOrder(intList);

            Console.WriteLine("Int 数据列表随机排序.");
            for (int i = 0; i < intRandomList.Count; i++)
            {
                Console.Write("{0}  ", intRandomList[i]);
            }
            Console.WriteLine();



            // 测试 string 类型的.
            RandomOrder <string> stringRandom = new RandomOrder <string>();

            List <string> stringList = new List <string>()
            {
                "A", "B", "C", "D", "E", "F", "G",
            };

            List <string> stringRandomList = stringRandom.DoRandomOrder(stringList);

            Console.WriteLine("string 数据列表随机排序.");
            for (int i = 0; i < stringRandomList.Count; i++)
            {
                Console.Write("{0}  ", stringRandomList[i]);
            }
            Console.WriteLine();
        }