Tuesday, September 22, 2015

"if any" is a little easier to read than "if count is greater than zero" in C#

List<AwfulError> awfulErrors = GetAwfulErrors();
if (awfulErrors.Any())
{

 
 

...is less ghetto than...

List<AwfulError> awfulErrors = GetAwfulErrors();
if (awfulErrors.Count > 0)
{

No comments:

Post a Comment