您的位置:首页 > 其它

写一方法来实现两个变量的交换。在主调函数中定义两个整型变量,并初始化,调用交换方法,实现这两个变量的交换。(使用ref参数)

2015-12-18 19:29 871 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
int a = 10;
int b = 15;
Test(ref a, ref b);
Console.WriteLine("现在a的值是{0},b的值是{1}",a,b);
Console.ReadKey();
}

static int Test(ref int a,ref int b)
{
int temp = a;
a = b;
b = temp;
return 20;
}

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: