问题描述
|
检查此方法:
public static void Swap(ref int i,ref int j)
{
int aux=i;
i=j;
j=aux;
}
比这更有效吗?
public static void Swap1(int[] a,int i,int j)
{
int aux=a[i];
a[i]= a[j];
a[j]=aux;
}
我正在使用以下方法:
static void Main(string[] args)
{
int[] a = { 5,4,3,1 };
Swap(a[1],a[2]);
Swap(a,1,2);
}
哪种方法更有效?为什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)