
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
How to sort an array in C#?
The following is the integer array.
int[] arr = { 99, 43, 86 };
To sort, use the Sort() method.
Array.Sort(arr);
The following is the complete code displaying how to sort an array in C# using the Sort() method.
Example
using System; class Demo { static void Main() { int[] arr = { 99, 43, 86 }; // sort Array.Sort(arr); Console.WriteLine("Sorted List"); foreach (int res in arr) { Console.Write("
"+res); } Console.WriteLine(); } }
Output
Sorted List 43 86 99
- Related Articles
- How to use std::sort to sort an array in C++
- How to sort an array of dates in C/C++?
- How to sort an Array using STL in C++?
- Sort an Array in C++
- C program to sort an array in an ascending order
- C program to sort an array by using merge sort
- How to sort an array elements in android?
- C# program to sort an array in descending order
- C program to sort an array in descending order
- Sort an Array of string using Selection sort in C++
- How do you sort an array in C# in ascending order?
- How do you sort an array in C# in descending order?
- Sort an array in descending order using C#
- How to sort an ArrayList in C#?
- Sort an array according to the order defined by another array in C++

Advertisements