问题描述
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceConsoleApplication1{classNumber{publicint[]number;publicNumber(int[]number){this.number=number;}}classOtherNumber{publicNumber[]number;publicOtherNumber(Number[]number){this.number=number;}}classProgram{staticvoidMain(string[]args){Number[]numbers=newNumber[2];numbers[0]=newNumber(newint[]{1,2});numbers[1]=newNumber(newint[]{3,4});OtherNumberother=newOtherNumber(numbers);}}}OtherNumberother=newOtherNumber(numbers);是不是OtherNumber类中的number为{1,2,3,4}????
解决方案
解决方案二:
OtherNumber类实例中的number成员是Number[]类型的,所以不能认为是{1,2,3,4}。other.number[0].number是{1,2}other.number[1].number是{3,4}
解决方案三:
引用楼主的回复:
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceConsoleApplication1{classNumber{publicint[]number;publicNumb……
OtherNumber类有一个Number类型的成员Number[]numbers=newNumber[2];//这两个对象是独立的numbers[0]=newNumber(newint[]{1,2});numbers[1]=newNumber(newint[]{3,4});因此你说的numbers[0]numbers[1]没什么关系,你说的结论不成立
解决方案四:
引用2楼的回复:
引用楼主的回复:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceConsoleApplication1{classNumber{publicint[]number;publicNumb……OtherNu……
能说的详细点吗谢谢了