-1

I am analyzing a program in the Exceptions section, but i don't understand what this piece of code do:

if (obj.ValidationExceptions.Exists(
    delegate(Exceptions.ValidationException x) {
        return x.Type == Exceptions.ValidationExceptionType.Error;
    }))
        return false;

Can anyone can put this code in other simple other way, avoiding using anonymous methods?

Dennis_E
  • 8,751
  • 23
  • 29
Aben
  • 45
  • 1
  • 7

1 Answers1

1

It uses Exists method from List<T> type to verify, whether any exception from ValidationExceptions is of type Exceptions.ValidationExceptionType.Error.

It is more less the same as

foreach(var validationError in obj.ValidationExceptions)
{
    if(validationError.Type == Exceptions.ValidationExceptionType.Error)
    {
        return false;
    }
}
tdragon
  • 3,209
  • 1
  • 16
  • 17