值和引用

using System;
using System.Collections.Generic;
using System.Text;

namespace 值和引用
{
    class Program
    {
        public void swap(ref int x,ref int y)
        {
            int wy = x;
            x = y;
            y = wy;
        }

        static void Main(string[] args)
        {
            int a = 100, b = 200;
            Console.WriteLine("之前:a:{0},b:{1}", a, b);
           Program loves=new Program ();
           loves.swap(ref a,ref b);
            Console.WriteLine("之后:a:{0},b:{1}", a, b);
            Console.Read();
          
        }
    }
}

posted on 2009-11-20 21:28  记住昨天,迎接明天  阅读(111)  评论(0编辑  收藏  举报