ThenBy() পদ্ধতি ব্যবহার করে একটি সিকোয়েন্সের উপাদান들을 সাজান।
নিচে একটি স্ট্রিং অ্যারে দেওয়া হলো।
string[] str = { "AAA", "AAAA", "A", "AAAAA", "AAAAAAAAA" };এখন, ল্যাম্বড এক্সপ্রেশন ব্যবহার করে ThenBy() পদ্ধতির ভেতরে শর্ত সেট করুন যাতে স্ট্রিংগুলো তাদের অক্ষরের সংখ্যা অনুযায়ী সাজানো হয়।
IEnumerable<string> res = str.AsQueryable() .OrderBy(alp => alp.Length).ThenBy(alp => alp);
উদাহরণ
using System; using System.Linq; using System.Collections.Generic; public class Demo { public static void Main() { string[] str = { "AAA", "AAAA", "A", "AAAAA", "AAAAAAAAA" }; IEnumerable<string> res = str.AsQueryable() .OrderBy(alp => alp.Length).ThenBy(alp => alp); foreach (string arr in res) Console.WriteLine(arr); } }আউটপুট
A AAA AAAA AAAAA AAAAAAAAA