I was working in a custom control today that exposes a dependency property of type System.Collections.ObjectModel.ObservableCollection<System.DateTime>.  After typing that type name a few times I decided it was time for a using statement at the top of the file to shorten things up.  But even ObservableCollection<DateTime> is pretty long.

I recalled reading about how applying the using statement to create aliases.  I wasn’t sure if it would, but sure enough, the following worked like a charm:

   1: using DateTimeList = System.Collections.ObjectModel.ObservableCollection<System.DateTime>;

That lets me declare my property as a DateTimeList, shortening up the syntax significantly.  Here’s a comparison.

With a typical “using System.Collections.ObjectModel”:

   1: public static ObservableCollection<DateTime> GetSelectedDates(Calendar calendar)
   2: {
   3:   return (ObservableCollection<DateTime>)calendar.GetValue(SelectedDatesProperty);
   4: }

With the DateTimeList alias:

   1: public static DateTimeList GetSelectedDates(Calendar calendar)
   2: {
   3:   return (DateTimeList)calendar.GetValue(SelectedDatesProperty);
   4: }


The usage feels really nice, but I wondered what others think.  Is this alias really cool or just plain wrong?