This article illustrates the different techniques to sort characters of a string in alphabetical order in C#.

We can use LINQ to sort characters of a string in alphabetical order in C#. The idea is to use LINQ’s OrderBy() method to create a sorted collection of all characters in the string, and then combine all characters together with the String.Concat() method.

Download  Run Code

 
Another option is to convert the string to a character array and sort it, and then pass the sorted character array to the string constructor to get a sorted string instance. The following code example demonstrates this:

Download  Run Code

That’s all about sorting characters of a string in alphabetical order in C#.