string[] stuff = ....;
if (stuff.Contains(“item”))
{
...
}
string[] arr = new string[] { “RR US”, “RR India”, “RR UK” };
if (!((IList<string>)arr).Contains(“India”))
{
System.Console.WriteLine ("Correct! We are working with RR India");
}
bool found =false;
foreach (string s in array)
{
if (s.Equals(“item”))
{
found =true;
break;
}
}
if (found)
{
........
}
bool exists = Array.IndexOf(arr, "RR India") >= 0
No doubt this is an alternative solution solutions. This may differ in terms of performance.
But, this is for c# 2.0 and as explained above .NET Framework 2.0 does provide a Contains() method on any Array object. So this may helpful for framework wise comparison.
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (5)
Commented:
Commented:
i will definitely use this in future ...
thanks..
Commented:
Commented:
Commented: