Get or set the element at the specified index in CSharp
Description
The following code shows how to get or set the element at the specified index.
Example
using System;/* www.j ava2 s . c o m*/
using System.Collections;
public class Example
{
public static void Main()
{
ArrayList stringList = new ArrayList();
stringList.Add("a");
stringList.Add("abc");
stringList.Add("abcdef");
stringList.Add("abcdefg");
Console.WriteLine(stringList[2]);
stringList[2] = "java2s.com";
Console.WriteLine(stringList[2]);
}
}
The code above generates the following result.