新聞中心
C#有很多值得學(xué)習(xí)的地方,這里我們主要介紹C#二維數(shù)組,包括介紹聲明C#二維數(shù)組是這么聲明int[,] myInt等方面。

成都創(chuàng)新互聯(lián)公司服務(wù)項(xiàng)目包括唐山網(wǎng)站建設(shè)、唐山網(wǎng)站制作、唐山網(wǎng)頁制作以及唐山網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,唐山網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到唐山省份的部分城市,未來相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
C#二維數(shù)組
- publicclassArray2D...{
- publicstaticvoidmain(String[]args)...{
- intmyInt[][]=newint[5][10];
- //遍歷,給數(shù)組中的每一個(gè)數(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是聲明一個(gè)交錯(cuò)數(shù)組,聲明C#二維數(shù)組是這么聲明int[,] myInt,上面的代碼如果換成C#的,需要如下表示:
- classclsArrat2D
- {
- /**////
- ///應(yīng)用程序的主入口點(diǎn)。
- /// summary>
- [STAThread]
- staticvoidMain(string[]args)
- {
- int[,]myInt=newint[5,10];
- //遍歷,給數(shù)組中的每一個(gè)數(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ù)組中每一個(gè)元素的個(gè)數(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ù)組
當(dāng)前地址:http://www.dlmjj.cn/article/cdhjooi.html


咨詢
建站咨詢
