using System;
public class SamplesArray {
public static void Main() {
String[] myArr = { "A", "B", "C", "D"};
ArraySegment<String> myArrSegAll = new ArraySegment<String>( myArr );
PrintIndexAndValues( myArrSegAll );
ArraySegment<String> myArrSegMid = new ArraySegment<String>( myArr, 2, 5 );
PrintIndexAndValues( myArrSegMid );
myArrSegAll.Array[3] = "LION";
PrintIndexAndValues( myArrSegMid );
}
public static void PrintIndexAndValues( ArraySegment<String> arrSeg ) {
for ( int i = arrSeg.Offset; i < (arrSeg.Offset + arrSeg.Count); i++ ) {
Console.WriteLine( " [{0}] : {1}", i, arrSeg.Array[i] );
}
}
public static void PrintIndexAndValues( String[] myArr ) {
for ( int i = 0; i < myArr.Length; i++ ) {
Console.WriteLine( " [{0}] : {1}", i, myArr[i] );
}
}
}