Array.contains() in asp.net
At array we don't have Contains() function directly, but we have an extension function of array in LINQ. we have so many extension functions in LINQ but we need to declare namespace for those.
i.e system.linq
Hi
All
For contains of array in c# so many of us using for loop which is like this below code
public void test()
{
string[] k = { "shiva", "kumar", "ans" };
foreach (string kk in k)
{
if (kk == "shiva")
{
//somthing
}
}
}
At array so many of developers using for loop to find an element in an array
instead of that we can use contains() function. This is an extension function from system.Linq namespace. If you declare this namespace in your c# file then only you can get this extension function else where you cannot get that.
EX
public void test()
{
string[] k = { "shiva", "kumar", "ans" };
if (k.Contains("shiva"))
{
//somthing
}
}
Syntax of Contains is
public static bool Contains
this IEnumerable
TSource value
)
For more info please refer the below link.
msdn.microsoft.com/en-us/library/bb352880.aspx
Thanks
Siva kumar.A