Monday 8 May 2006

I need more syntactic sugar

I am really excited about extension methods and once C# 3.0 is released I’m going to extend every collection class with IsEmpty, IsNotEmpty functions. They should look like that:


public static bool IsEmpty(this ArrayList list)
{
return list.Count == 0;
}

public static bool IsNotEmpty(this ArrayList list)
{
return list.Count > 0;
}


I know that it’s not big deal but I would rather write: if (list.IsEmpty()) then if (list.Count == 0). The first one is just much more readable.

No comments:

Post a Comment