//Visual Basic 2010 System.Array Collecties Arrays public class Example2 { public virtual void Main() { byte[] array1 = new byte[] { 0, 0}; Console.WriteLine(array1.Length); Console.WriteLine(array1.Rank); Console.WriteLine(array1.GetLength(1)); Console.WriteLine(array1.GetLowerBound(0)); Console.WriteLine(array1.GetUpperBound(1)); int[] array2 = new int[] { 1, 2, 3, 2, 5}; int searchValue = 2; Console.WriteLine(Array.IndexOf(array2, searchValue)); Console.WriteLine(Array.LastIndexOf(array2, searchValue, 3)); Console.WriteLine(Array.IndexOf(array2, searchValue, 2, 1)); this.array2(3) = 4; Console.WriteLine(Array.BinarySearch(array2, searchValue)); this.PrintArray(array2); Array.Reverse(array2); this.PrintArray(array2); Array.Reverse(array2, 1, 3); this.PrintArray(array2); string[] array3 = new string[] { "Paul", "John", "Jane"}; this.PrintArray(array3); Array.Sort(array3); this.PrintArray(array3); Array.Reverse(array3); this.PrintArray(array3); Array.Sort(array3, 1, 2); this.PrintArray(array3); Array.Clear(array3, 0, 2); this.PrintArray(array3); byte[] array4 = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9}; byte[] array5 = new byte[0]; Array.Copy(array4, array5, 6); this.PrintArray(array5); Array.Copy(array4, 2, array5, 1, 3); this.PrintArray(array5); Console.ReadLine(); } public static void PrintArray(Array array) { for (System.Collections.IEnumerator _it1 = array.GetEnumerator(); _it1.MoveNext(); ) { object element = ((object)(_it1.Current)); if ((element != null)) { Console.Write((element.ToString() + " - ")); } } Console.WriteLine(); } } //Bezoek www.vbvoorbeelden.be voor meer C# voorbeelden. //Copyright - De Wolf / vbvoorbeelden - 2003-2011 - Alle rechten voorbehouden.