[英]How to fix C# Jagged arrays Type Conversion Error
這來自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 []'
請幫忙。
更新:我是C#的新手,我認為該課程有錯誤: https : //courses.edx.org/courses/course-v1 : Microsoft+DEV204.3x+1T2019/courseware/ 3544566571fe4074b46541d73149ad8d/ c97ee813019947a0b2ba0dfb1f60b132/1? activate_block_id = block-v1%3AMicrosoft%2BDEV204.3x%2B1T2019%2Btype%40vertical%2Bblock%4008d10138ab7542969703766ee6eb1b03
我將向課程報告。
感謝您的評論和答復。 他們幫助。
就像評論中說的那樣,System.Type與int不同,我認為您想要這樣的東西:
Type[][] jaggedArray = new Type[10][];
jaggedArray[0] = new Type[5];
jaggedArray[1] = new Type[7];
jaggedArray[9] = new Type[21];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.