I found this on MSDN and some other blogs and articles:
void CheckListForThing()
{
for (int i = 0; i < ThingList.Count; i++)
{
//this part is strange to me, I can barely understand it, but for what it does it does exactly what I want
ObjectOnList = ThingList.Find(
delegate(ObjectOnListType _objectOnList)
{
return _objectOnList.VariableToCheck == i;
}
);
if (ObjectOnList != null) //check to see if an object on the list matches the variable compared to i
{
//do something
}
}
}
Id like to see how else I should use this to find stuff on lists, other ways to test for values.
also could someone explain to me what this is exactly
Find(
delegate(ObjectOnListType _objectOnList)
{
return _objectOnList.VariableToCheck == i;
}
);
what is a delegate, I cant make sense of what it is. Its like a temporary function command right?
how come you can do awesome things like “return a CheckedValue that is equal to Whatever”. Seems really useful. Can I do that other places besides in delegate?