Array lenght is NOT part of the type. So array length cannot be used as parameter signature. int[] a = new int[5]; int[] b = new int[6]; a.GetType() == b.GetType(); //trueint[,] x = new int[3, 3]; int[,] y = new int[4, 4]; x.GetType() == y.GetType(); //truechar[] m = new char[5]; byte[] n = new byte[5]; m.GetType() == n.GetType(); //false
private void function(int[] arrays)
{
//这里写代码是没有问题的
}
1、没有表明方法时候有返回值(我的代码中void表示没有返回值);
2、int[5] parra参数中不能有5,我们只能表示传递一个数组,但是不能在参数列表中限制数组中元素的个数。
还是不明白
传递的是数组的引用为什么就不可以限定长度?
why?
So array length cannot be used as parameter signature.
int[] a = new int[5];
int[] b = new int[6];
a.GetType() == b.GetType(); //trueint[,] x = new int[3, 3];
int[,] y = new int[4, 4];
x.GetType() == y.GetType(); //truechar[] m = new char[5];
byte[] n = new byte[5];
m.GetType() == n.GetType(); //false
private void func(int[] parra, int len)
{
if(len!=5)
return ;
}