Exemplo n.º 1
0
        static void Main(string[] args)
        {
            /* Class1 c = new Class1();
             * c.Add(8);
             * c.Add(9);
             * c.Add(10);
             * c.PrintLog();*/

            Class1 <int> array = new Class1 <int>();

            array.Add(12);
            Class1 <string> array1 = new Class1 <string>();

            array1.Add("字符串");
            array1.PrintLog();
        }
        static void Main(string[] args)
        {
            string encrypted = Encryption.Encrypt("Hitendra", true);

            Console.WriteLine(encrypted);
            string decrypted = Encryption.Decrypt(encrypted, true);

            Console.WriteLine(decrypted);

            Func <int, string, bool> ob = (int x1, string s) => s.Length > x1;

            ob(5, "Hello");
            Action <string, int> ob1 = (string x2, int s2) => Console.WriteLine($"{x2} and {s2.ToString()}");

            ob1("Test", 5);
            Test <int>(1); // this will work
            //Test<string>(""); Will not permitted since the T is struct
            Class1 c11 = new Class1();

            Console.WriteLine(c11.Test <float>(5.2f, 1.6f));
            Console.WriteLine(GeneratePassword(4, 2, 1, 1));
            int[] q   = { 0, 1, 2, 3, 4 };
            int[] r   = { 5, 6, 7, 8, 9 };
            int[] res = MergedArray(q, r);
            foreach (int item in res)
            {
                Console.WriteLine(item.ToString());
            }
            Class3 three = new Class4();

            three.Do();
            three.DoIt();
            int[] a      = { 1, 2, 3, 4, 5 };
            int[] p      = { 3, 4, 1, 8, 9 };
            int[] result = DoIntersection(a, p);
            Test  test   = new Test();//new Test("Hitendra Kumar", 35);

            test.DisplayName();
            PrintPiramid(7);
            int factorial = Factorial(6, 1);

            WriteLine($"Factorial value of given number is :{factorial}");
            WriteLine($"Calling Expression Bodied Method: {Test(5)} ");
            int[] arr   = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            int   total = 0;

            total = RecursiveMethod(0, arr, 0);
            Console.WriteLine(total);

            Console.WriteLine(CheckSquareRoot <Boolean>(25));
            int[] array = { 1, 2, 3, 4, 5 };
            Array.ForEach(array, i => Console.WriteLine(i));
            Class1 c = new Class1();

            c.Add(3f, 3);
            c.Add(8, 7f);
            string x  = "kkk";
            Class1 c1 = new Class2();

            c1.Calculate();
            ((Class2)c1).Calculate();
            c1.Add(8, 9);
            c1.Test <int>(null, 5);
            using (BaseDisposable b = new ChildClassA())
            {
            }

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn {
                ColumnName = "Name", DataType = typeof(string)
            });
            dt.Columns.Add(new DataColumn {
                ColumnName = "Age", DataType = typeof(int)
            });
            DataRow dr = dt.NewRow();

            dr["Name"] = "Hitendra";
            dr["Age"]  = 35;
            dt.Rows.Add(dr);
            //DataRow dr = new DataRow(new DataColumn { ColumnName="Name", DataType=typeof(string)}));

            var row = dt.AsEnumerable().ToList();

            SomeMethod(dt);
            row.ForEach(d => Console.WriteLine(d["Name"] + "" + d["Age"]));
        }