Hey, I have this code here:
ArrayList arrayList = new ArrayList();
arrayList.add("one");
arrayList.add("two");
arrayList.add("three");
List<DataRow> dataList = GetDataList(some params);
Now I want to check if arrayList contains ther elements from dataList. The string is at itemarray[0] in dataList. Is there a nice short code version to do that?
Thanks 🙂
In .NET 3.5 to check if all the elements from one list are contained in another list:
Or you can do it using a combination of Except and Any:
In your example you are using an
ArrayList. You should change this toList<object>orList<string>to use these methods. Otherwise you can writearrayList.Cast<object>().