একটি অ্যারে ডেটা সংগ্রহ সংরক্ষণের জন্য ব্যবহৃত হয়, কিন্তু এটি একই টাইপের ভেরিয়েবল সমষ্টি হিসেবে চিন্তা করা অধিক সুবিধাজনক যা সন্নিবিষ্ট মেমরি লোকেশনে সংরক্ষিত থাকে।
সিঙ্গল-ডাইমেনশনাল অ্যারে সংজ্ঞায়িত করা
int[] runs = new int[10];
একই লাইনে ইনিশিয়ালাইজেশন
int[] runs = new int[5] {125, 173, 190, 264, 188};
সম্পূর্ণ উদাহরণ
using System;
namespace Program {
class Demo {
static void Main(string[] args) {
int[] runs = new int[5] {125, 173, 190, 264, 188};
int i,j;
for (j = 0; j < 5; j++ ) {
Console.WriteLine("Innings score of Cricketer[{0}] = {1}", j, runs[j]);
}
Console.ReadKey();
}
}
}
আউটপুট
Innings score of Cricketer[0] = 125 Innings score of Cricketer[1] = 173 Innings score of Cricketer[2] = 190 Innings score of Cricketer[3] = 264 Innings score of Cricketer[4] = 188