Miguel,
Well, like it or not, you are going to have to have a loop somewhere, it
just might not be apparent.
In 3.5, if you want to see if there is any item in the list where
NameParameter = some value, you can do this:
// The list.
List<MyClassmyList = ...;
// The value to check against.
string nameParameterValue = ...;
// Does it contain the value?
bool containsValue = myList.Any(item =item.NameParameter ==
nameParameterValue);
The Any extension method is going to perform the loop for you.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"shapper" <md*****@gmail.comwrote in message
news:c6**********************************@e6g2000p rf.googlegroups.com...
Hello,
I have a List(Of MyClass).
MyClass has two properties: Name and City.
I want to find, without using a loop, if there is a item where name =
NameParameter.
I know that I can use a Predicate but in .NET 2.0 Predicates do not
accepted Parameters.
Because of that I used a Predicate Wrapper.
With .NET 3.5 I know this has changed and now it is much easier to do
something like this.
However, I can't find any example of it.
Can someone, please, help me out?
Thanks,
Miguel