Example #1
0
        static void Main2(string[] args)
        {
            My <int> myobj = new My <int>();

            myobj.Add(1);     //T 好 object好:
            //myobj.Add("aa");//更安全,第一时间告诉 放的不合适
            myobj.Add(2);     //不需要类型转换 性能更好; object<int 很多 性能
            myobj.Add(3);
            myobj.Add(4);
        }
Example #2
0
        static void Main3(string[] args)
        {
            string a = "aas";
            string b = "bb";

            Console.WriteLine(a);
            Console.WriteLine(b);
            My <string> my = new My <string>();

            my.Swap(ref a, ref b);
            //Fun????
            Console.WriteLine(a);
            Console.WriteLine(b);

            Console.ReadKey();
        }
Example #3
0
        static void Main1(string[] args)
        {
            My <int> myobj = new My <int>();

            myobj.Add(1);

            My <String> myobj2 = new My <String>();

            myobj2.Add("aa");

            Your your1 = new Your();

            //your1.Add<int>(1);
            //your1.Add<int>(2);
            your1.Add(1);
            your1.Add(2);
        }