Anonymous user
Sorting algorithms/Bubble sort: Difference between revisions
→{{header|C sharp|C#}}
(add C# radix sort) |
|||
Line 415:
</pre>
<lang csharp>using System;
using System.Collections.Generic;
namespace
{
public static class
{
//The "this" keyword before the method parameter identifies this as a C# extension
static void Sort(int[] old)▼
//method, which can be called using instance method syntax on any generic list,
//without having to modify the generic List<T> code provided by the .NET framework.
public static void BubbleSort<T>(this List<T> list) where T : IComparable
{
int
{
for (int i = 0; i < itemCount; i++)
{
madeChanges = true;
}▼
}
} while
▲ }
}
}
//A short test program to demonstrate the BubbleSort. The compiler will change the
//call to testList.BubbleSort() into one to BubbleSortMethods.BubbleSort<T>(testList).
class Program
{
{
List<int
}
}
|