【发布时间】:2019-01-30 04:06:20
【问题描述】:
这是来自 MS 在 edx 上的 C# 数据结构和算法课程。
"锯齿状数组 锯齿状数组只是一个数组的数组,每个数组的大小可以变化。”
int[][] jaggedArray = new int[10][];
jaggedArray[0] = new Type[5];//cannot implicitly convert type 'system.Type[]' to 'int[]'
jaggedArray[1] = new Type[7];//cannot implicitly convert type 'system.Type[]' to 'int[]'
jaggedArray[9] = new Type[21];//cannot implicitly convert type 'system.Type[]' to 'int[]'
预期结果:没有错误
实际结果:无法将类型'system.Type[]'隐式转换为'int[]'
请帮忙。
我会向课程报告。
感谢您的评论和回答。他们提供帮助。
【问题讨论】:
-
您应该声明具有相同类型的锯齿状数组元素,例如
jaggedArray[0] = new int[5]。请记住System.Type!=int。
标签: c# jagged-arrays