Using LINQ, can I verify a property has the same value for all objects?

I believe this would work:

public bool Validate(Crate crate)
{
    return crate.Sections
                .Select(x => x.Value.PixelsWide)
                .Distinct()
                .Count() < 2;
}

This will return true if crate.Sections is empty as well as when the elements are all the same (which is the behavior of your current function).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)