একটি অ্যারের উপাদানগুলি পরিবর্তন করতে নির্বাচন পদ্ধতি ব্যবহার করুন৷
৷নিম্নলিখিতটি আমাদের স্ট্রিং অ্যারে।
string[] stationery = { "diary", "board", "pencil", "whiteboard" }; সিলেক্ট মেথড নীচে দেখানো হিসাবে ল্যাম্বডা এক্সপ্রেশনগুলিও নির্দিষ্ট করে −
উদাহরণ
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
string[] stationery = { "diary", "board", "pencil", "whiteboard" };
var res = stationery.AsQueryable().Select((item, index) => new { result = item.Substring(0, index + 4) });
foreach (var str in res) {
Console.WriteLine("{0}", str);
}
}
} আউটপুট
{ result = diar }
{ result = board }
{ result = pencil }
{ result = whitebo }