Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

selection sort in c#

public static void Sort<T>(T[] array) where T : IComparable 
{
    for (int i = 0; i < array.Length - 1; i++) 
    {
        int minIndex = i; 
        T minValue = array[i];
        for (int j = i + 1; j < array.Length; j++) 
        {
            if (array[j].CompareTo(minValue) < 0)
            {
             	 minIndex = j; 
                 minValue = array[j]; 
            } 
        } 
        Swap(array, i, minIndex); 
    }
}
private static void Swap<T>(T[] array, int first, int second)
{
	T temp = array[first]; 
  	array[first] = array[second]; 
  	array[second] = temp;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# datetime format ymd 
Csharp :: response redirect new tab 
Csharp :: c-sharp - get current page url/path/host 
Csharp :: int to bool c# 
Csharp :: c# for loop 
Csharp :: how to check if a path is a directory or file c# 
Csharp :: what does static mean in c# 
Csharp :: wpf button 
Csharp :: wpf make size fill all grid 
Csharp :: can you have multiple statement in a case c# 
Csharp :: gameobject on click unity 
Csharp :: c# add string to array 
Csharp :: c# change label from thread 
Csharp :: difference between alpha and beta testing 
Csharp :: unity random point in sphere 
Csharp :: shorthand if c# 
Csharp :: particle system start color 
Csharp :: c# oops concept 
Csharp :: c# get application root path directory 
Csharp :: fluent assertion exception 
Csharp :: write last element of dictionary c# 
Csharp :: datetime check null c# 
Csharp :: how to play multiple sound at once on c# windows form 
Csharp :: c# isdigit mehod 
Csharp :: integer required asp.net core 
Csharp :: c# empty array 
Csharp :: c# tell if list object is empty 
Csharp :: convert html to pdf c# 
Csharp :: if checkbox checked in c# 
Csharp :: how to stop a form c# 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =