新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
簡單描述C#二維數(shù)組
C#有很多值得學習的地方,這里我們主要介紹C#二維數(shù)組,包括介紹聲明C#二維數(shù)組是這么聲明int[,] myInt等方面。

成都創(chuàng)新互聯(lián)公司服務(wù)項目包括唐山網(wǎng)站建設(shè)、唐山網(wǎng)站制作、唐山網(wǎng)頁制作以及唐山網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,唐山網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到唐山省份的部分城市,未來相信會繼續(xù)擴大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
C#二維數(shù)組
- publicclassArray2D...{
- publicstaticvoidmain(String[]args)...{
- intmyInt[][]=newint[5][10];
- //遍歷,給數(shù)組中的每一個數(shù)組賦值
- for(inti=0;i
;i++)...{ - for(intj=0;j
[0].length;j++)...{ - myInt[i][j]=i*j;
- }
- }
- System.out.println("myInt.length="+myInt.length+",myInt[0].
length="+myInt[0].length);- //輸出數(shù)組每一維的下限和上限
- for(inti=0;i
;i++)...{ - for(intj=0;j
[0].length;j++)...{ - System.out.println("myInt["+i+"]["+j+"]="+myInt[i][j]);
- }
- }
- }
- }
在C#中int[][] myInt是聲明一個交錯數(shù)組,聲明C#二維數(shù)組是這么聲明int[,] myInt,上面的代碼如果換成C#的,需要如下表示:
- classclsArrat2D
- {
- /**////
- ///應(yīng)用程序的主入口點。
- /// summary>
- [STAThread]
- staticvoidMain(string[]args)
- {
- int[,]myInt=newint[5,10];
- //遍歷,給數(shù)組中的每一個數(shù)組賦值
- for(inti=myInt.GetLowerBound(0);i<=myInt.GetUpperBound(0);i++)
- {
- for(intj=myInt.GetLowerBound(1);j<=myInt.GetUpperBound(1);j++)
- {
- myInt[i,j]=i*j;
- }
- }
- //輸出數(shù)組每一維的下限和上限
- for(inti=0;i
;i++) - {
- Console.WriteLine("{0}{1}{2}",i,myInt.GetLowerBound(i),myInt.GetUpperBound(i));
- }
- //遍歷,輸出二維數(shù)組中每一個元素的個數(shù)
- for(inti=myInt.GetLowerBound(0);i<=myInt.GetUpperBound(0);i++)
- {
- for(intj=myInt.GetLowerBound(1);j<=myInt.GetUpperBound(1);j++)
- {
- Console.WriteLine("myInt[{0},{1}]={2}",i,j,myInt[i,j]);
- }
- }
- Console.ReadLine();
- }
- }
以上介紹C#二維數(shù)組。
網(wǎng)站標題:簡單描述C#二維數(shù)組
網(wǎng)頁鏈接:http://m.fisionsoft.com.cn/article/cdhjooi.html


咨詢
建站咨詢
