I have an arraylist that contains items called Room. Each Room has a roomtype such as kitchen, reception etc. I want to check the arraylist to see if any rooms of that type exist before adding it to the list. Can anyone recommend a neat way of doing this without the need for multiple foreach loops?
(.NET 2.0)
I havent got access to the linq technology as am running on .net 2.0. I should have stated that in the question. Apologies
I would not use
ArrayListhere; since you have .NET 2.0, useList<T>and all becomes simple:Or with C# 3.0 (still targetting .NET 2.0)
Or with C# 3.0 and either LINQBridge or .NET 3.5:
(the
Anyusage will work with more types, not justList<T>)