Blog Stats
  • Posts - 148
  • Articles - 0
  • Comments - 92
  • Trackbacks - 14

 

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:
   1:  public static bool IsEmpty(this ArrayList list)
   2:  {
   3:    return list.Count == 0;
   4:  }
   5:   
   6:   
   7:  public static bool IsNotEmpty(this ArrayList list)
   8:  {
   9:    return list.Count > 0;
  10:  }

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.

Comments have been closed on this topic.
 

 

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
Copyright © Pawel Pabich