//Visual Basic 2008/2010 Sorteren van Arrays - Insertion Sort Arrays public class InsertionSortExample { void Main() { int count = 5; int upperbound = (count - 1); int[] numbers = new int[0]; int index; this.numbers(index) = ((((count + index) * 93) % 97) - (count / (index + 1))); Console.Write("unsorted array : "); Console.Write((this.numbers(index) + " ")); Console.WriteLine(); int unsortedCount = (count - 1); for (; (unsortedCount == 0); ) { int startIndexUnsortedPart = (count - unsortedCount); int backup = this.numbers(startIndexUnsortedPart); index = (startIndexUnsortedPart - 1); for (; ((index >= 0) && (this.numbers(index) > backup)); ) { this.numbers((index + 1)) = this.numbers(index); index = 1; } this.numbers((index + 1)) = backup; unsortedCount = 1; Console.Write("temporary array : "); Console.Write((this.numbers(index) + " ")); Console.WriteLine(); } Console.Write("sorted array : "); Console.Write((this.numbers(index) + " ")); Console.ReadLine(); } } //Bezoek www.vbvoorbeelden.be voor meer C# voorbeelden. //Copyright - De Wolf / vbvoorbeelden - 2003-2010 - Alle rechten voorbehouden.