using System;
using System.Collections.Generic;
namespace ConsoleApplication_C_Sharp
{
class Program
{
static void Main(string[] args)
{
String[] arr = {"C#", "C", "C++", "PHP", "VB.NET"};
IList<String> ilist = Array.AsReadOnly(arr);
Console.WriteLine(ilist[0]); // C#
try
{
ilist[0] = "Java"; // Error
}
catch (NotSupportedException e)
{
Console.WriteLine("{0} - {1}", e.GetType(), e.Message);
}
}
}
}
/*
run:
C#
System.NotSupportedException - Collection is read-only.
*/