सबसे पहले, एक स्ट्रिंग ऐरे सेट करें -
string[] arr = new string[] {
"Indian",
"Moroccon",
"American",
}; शब्दों को शब्दावली क्रम में क्रमबद्ध करने के लिए -
var sort = from a in arr orderby a select a;
उदाहरण
आइए देखें पूरा कोड -
using System;
using System.Linq;
class Program {
static void Main() {
string[] arr = new string[] {
"Indian",
"Moroccon",
"American",
};
var sort = from a in arr
orderby a
select a;
foreach(string res in sort) {
Console.WriteLine(res);
}
}
} आउटपुट
American Indian Moroccon