diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 28fe9ba..9f10c3c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -40,4 +40,5 @@ - [Rabin Khatiwada](https://github.com/rabinkhatiwada) - [Adrian Hernandez-Lopez](https://github.com/AdrianHL) - [Juan Benitez](https://github.com/juanbenitez) -- [Chaiyapat Tantiworachot](https://github.com/pixelart7) \ No newline at end of file +- [Chaiyapat Tantiworachot](https://github.com/pixelart7) +T- [Taha Bin Aziz](https://github.com/tahabinaziz) \ No newline at end of file diff --git a/source/snippets/csharp/index.md b/source/snippets/csharp/index.md index b06406f..94c4b37 100644 --- a/source/snippets/csharp/index.md +++ b/source/snippets/csharp/index.md @@ -25,3 +25,36 @@ private void Shuffle(string[] e) } } ``` +# C# + +## Bubble Sort + +Method to sort an arry using bubble sort + +```csharp + public static void Main(string[] args) + { + int[] a = { 3, 0, 2, 5, -1, 4, 1 }; + int t; + Console.WriteLine("Original array :"); + foreach (int aa in a) + Console.Write(aa + " "); + for (int p = 0; p <= a.Length - 2; p++) + { + for (int i = 0; i <= a.Length - 2; i++) + { + if (a[i] > a[i + 1]) + { + t = a[i + 1]; + a[i + 1] = a[i]; + a[i] = t; + } + } + } + Console.WriteLine("\n"+"Sorted array :"); + foreach (int aa in a) + Console.Write(aa + " "); + Console.Write("\n"); + + } +``` \ No newline at end of file