The Array.IsReadOnly property gets a value indicating whether the Array is read-only.
Firstly, set the array values −
Array arr = Array.CreateInstance(typeof(String), 3);
arr.SetValue("Electronics", 0);
arr.SetValue("Clothing", 1);Now let’s use the IsReadOnly property to find whether the Array is read-only. If the array is read-only, then it cannot be updated −
arr.IsReadOnly
The following is the complete example stating the usage of Array.IsReadOnly property −
Example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace lower {
class Program {
static void Main(string[] args) {
Array arr = Array.CreateInstance(typeof(String), 3);
arr.SetValue("Electronics", 0);
arr.SetValue("Clothing", 1);
Console.WriteLine("Lower Bound: {0}",arr.GetLowerBound(0).ToString());
Console.WriteLine("isReadOnly: {0}",arr.IsReadOnly.ToString());
Console.ReadLine();
}
}
}Output
Lower Bound: 0 isReadOnly: False