Single() পদ্ধতি ব্যবহার করে একটি সিকোয়েন্সের শুধুমাত্র একটি উপাদান পান।
ধরা যাক আমাদের একটি স্ট্রিং অ্যারে আছে যেখানে শুধুমাত্র একটি উপাদান আছে।
string[] str = { "one" }; এখন, উপাদান পান।
str.AsQueryable().Single();
এখানে আমাদের কোড।
উদাহরণ
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
string[] str = { "one" };
string res = str.AsQueryable().Single();
Console.WriteLine(res);
}
} আউটপুট
one