int[] arry = { 23, 34,10, 11, 56 };
int[] Output = { };
for (int i = 0; i < arry.Length; i++)
{
int temp= arry[i];
for (int j = 0; j < arry.Length; j++)
{
if (temp > arry[j] && Array.IndexOf(Output, temp)==-1)
{
temp = arry[j];
}
}
Output[i] = temp;
}
when I add temp to Output[] compiler return run time error "Index was outside the bounds of the array."
after slove Bubble Sort ...
int[] array = { 23, 34, 10, 11, 56,0,2 };
for (int i = 0; i < array.Length-1 ; i++)
{
int temp;
for (int j = 0; j < array.Length-1 ; j++)
{
if (array[j] > array[j + 1])
{
temp = array[j];
array[j] = array[j + 1];
array[j + 1] = temp;
}
}
}
foreach (var item in array)
{
Console.WriteLine("Number:{0}", item);
}
Console.ReadKey();
thanks for Evry One