PDA

View Full Version : سوال: پیمایش آرایه در C#



roohallaharab
چهارشنبه 24 اردیبهشت 1393, 18:55 عصر
برای پیمایش آرایه ذیل چگونه foreach را تعریف کنم؟





int[][] a=new int[2][];
a[0]=new int[]{1,2,3}
a[1]=new int[]{4,5};

danialafshari
چهارشنبه 24 اردیبهشت 1393, 19:24 عصر
با سلام
ساختار Foreach رو مطالعه فرمائید
یک مثال:
usingSystem;
class Program
{
static void Main()
{
Int32[] MyArray = { 2,4,6,8,10,12,14,16,18};


for (int i = 0; i < MyArray.Length; i++)
{
Console.Write(" {0} ",MyArray[i]);
}

Console.ReadKey();

}
}
http://www.hamcodi.ir/article/209
موفق باشید