सबसे पहले, एक सरणी सेट करें -
int[] arr = {6, 3, 8, 4}; अब, सरणी का आकार प्राप्त करने के लिए लंबाई संपत्ति का उपयोग करें -
arr.Length
आइए देखें पूरा कोड -
उदाहरण
using System;
namespace Demo {
public class Demo {
public static void Main(string[] args) {
int[] arr = {6, 3, 8, 4};
Console.WriteLine("Array...");
foreach (int i in arr) {
Console.Write(i + " ");
}
Console.WriteLine("\nSize of Array: "+arr.Length);
}
}
} आउटपुट
Array... 6 3 8 4 Size of Array: 4