| درس دهم - بخش دوم |
|
|
|
| نوشته شده توسط فرزاد | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ﻣﺜﺎل : ﻳﻚ ﺑﺮﻧﺎﻣـﻪ ی ﺳـﻲ ﺷـﺎرپ ﺟﺪﻳـﺪ console را در VS.NETﺑـﺎز ﻛﻨﯿـﺪ و ﻧـﺎم آﻧـﺮا دراﺑﺘـﺪا ex۱۹اﻧﺘﺨـﺎب ﻧﻤﺎﻳﯿـﺪ. ;using System namespace ex۱۹ } class Class۱ { [STAThread] static void Main(string[] args) { const int rows = ۴; const int columns = ۳; // declare a ۴x۳ integer array int[,] rectangularArray = new int[rows, columns]; // populate the array for (int i = ۰;i < rows;i++) { for (int j = ۰;j<columns;j++) { rectangularArray[i,j] = i+j; } } // report the contents of the array for (int i = ۰;i < rows;i++) { for (int j = ۰;j<columns;j++) { Console.WriteLine("rectangularArray[{۰},{۱}] = {۲}", i,j,rectangularArray[i,j]); } } Console.ReadLine(); } } }
: ﺗﻮﺿﯿﺤﺎﺗﻲ در ﻣﻮرد ﻛﺪ ﻓﻮق new int[rows, columns] : اﺳﺘﻔﺎده از آراﻳﻪ ھﺎی ﭼﻨﺪ ﺑﻌﺪی
. اﻧﺘﺨـﺎب ﻧﻤﺎﻳﯿـﺪex۲۰ ﺑـﺎز ﻛﻨﯿـﺪ و ﻧـﺎم آﻧـﺮا دراﺑﺘـﺪاVS.NET را در console ﻣﺜﺎل : ﻳﻚ ﺑﺮﻧﺎﻣـﻪ ی ﺳـﻲ ﺷـﺎرپ ﺟﺪﻳـﺪ ﺳﭙﺲ ﻛﺪ زﻳﺮ را درون آن ﺑﻨﻮﻳﺴﯿﺪ : using System; namespace ex۲۰ { class Class۱ { [STAThread] static void Main( string[] args ) { const int rows = ۴; const int columns = ۳; // imply a ۴x۳ array int[,] rectangularArray = { {۰,۱,۲}, ,{۵,۴,۳} ,{۸,۷,۶} {۱۱,۰۱,۹} ;{ (++for (int i = ۰;i < rows;i } (++for (int j = ۰;j<columns;j } ,"{۲} = [{۱},{۰}]Console.WriteLine("rectangularArray ;([i,j,rectangularArray[i,j { { { { { ﺗﻮﺿﯿﺤﺎﺗﻲ در ﻣﻮرد ﻛﺪ ﻓﻮق : ١- در ﺣﻘﯿﻘﺖ ﻣﺜﺎل ﻓﻮق ﺗﻌﺮﻳﻒ آراﻳﻪ اﻳﻲ از آراﻳﻪ ھﺎ ﺑﻮد. ٢- ﭼﻮن ﻣﻘﺪار دھﻲ اوﻟﯿﻪ ﺑﻪ ﺻﻮرت واﺿﺤﻲ اﻧﺠﺎم ﺷـﺪه ﻧﯿـﺎزی ﺑـﻪ ذﻛـﺮ اﺑﻌـﺎد آراﻳـﻪ ﺑـﻪ ﺻـﻮرت ﺻـﺤﯿﺢ وﺟـﻮد ﻧﺪاﺷﺖ.
Powered by !Comment 3.26
3.26 Copyright (C) 2009 VCSharp.ir / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved." |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||


