Contains() মেথড সিকোয়েন্সে নির্দিষ্ট মান আছে কিনা চেক করে (বুলিয়ান রিটার্ন)।
উদাহরণ
using System;
using System.Linq;
using System.Collections.Generic;
class Demo
{
static void Main()
{
string[] arr = { "Bag", "Pen", "Pencil" };
string str = "Pen";
bool res = arr.AsQueryable().Contains(str);
Console.WriteLine("String Pen is in the array? " + res);
}
}
আউটপুট
String Pen is in the array? True
কেস-সেনসিটিভ। কেস-ইনসেনসিটিভের জন্য StringComparer.OrdinalIgnoreCase ব্যবহার করুন।