Beispiel #1
0
 public static void addtoamount(this money money, decimal amountToAdd)
 {
     money.Amount += amountToAdd;
     // r//eturn true;
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            /*
             * phoencustomer mycus = new phoencustomer();
             * phonecusstruct mycusstruct = new phonecusstruct();
             * mycus.firstname = "simon";
             * mycus.lastname = "jack";
             * mycus.custmerid = 1999;
             * mycusstruct.lastname = "mark";
             * Console.WriteLine(mycusstruct.lastname);
             * Console.WriteLine(mycus.firstname+" "+mycus.lastname);
             * Console.WriteLine(mycus.custmerid);
             *
             * Console.WriteLine("π的值为 " + MathTest.GetPi());
             * int x = MathTest.GetSquareOf(5);
             * Console.WriteLine("5的平方是 " + x);
             * MathTest math = new MathTest();
             * math.Value = 30;
             * Console.WriteLine("新的value值为 " + math.Value);
             * Console.WriteLine("30的平方为 " + math.GetSquare());
             * int cd=0;
             * int i = 0,y=0;
             * int[] ints = { 0, 1, 2, 4, 8 };
             * Console.WriteLine("i=" + i);
             * Console.WriteLine("ints[0]=" + ints[0]);
             * Console.WriteLine("calling somefun.");
             * somefun(ints,y, ref cd, out i);
             * Console.WriteLine("i=" + i);
             * Console.WriteLine("ints[0]=" + ints[0]+" "+cd+" "+y);
             *
             * fullname("jhon", "Doe");
             * Console.WriteLine();*/
            Console.WriteLine(DateTime.MaxValue);
            Console.WriteLine();
            Console.WriteLine("userp:backcolor is " + userp.backcolor.ToString());
            //弱引用

            /*    WeakReference mathref = new WeakReference(new MathTest());
             *  MathTest math;
             *  if(mathref.IsAlive)
             *  {
             *      math=mathref.Target as MathTest;
             *      math.Value = 30;
             *      Console.WriteLine("value field of math....." + math.Value);
             *      Console.WriteLine("square of 30 id  " + math.GetSquare());
             *  }
             *  else
             *  {
             *      Console.WriteLine("ref is nor available");
             *  }
             *  GC.Collect();
             *  if(mathref.IsAlive)
             *  {
             *     math= mathref.Target as MathTest;
             *  }
             *  else
             *  {
             *      Console.WriteLine("not available");
             *  }
             */
            //弱引用结束

            money cash = new money();

            cash.Amount = 40M;
            Console.WriteLine("cash1 " + cash.ToString());
            cash.addtoamount(40M);
            Console.WriteLine(cash.ToString());
            Console.ReadLine();
        }