Seems I've done rather well this month in the CodeProject article competions. With two articles I managed to take out three awards. I'm chuffed!
So, ok, now I get to gloat a bit. ;)
I won the Best C# and Best Overall article categories with this article.
And I won the Best VB.NET article category with this article.
Kudos goes out to my usual nemesis and, at the same time, good friend Sacha Barber. Sacha's awesome Bread Crumb control could have won it. Likewise Colin's innovative Linq to Tree article was tops. See Sacha's TimeLineControl for a simply superb piece of work. I forsee it being a definite winner for April's comp.
Thanks also go out to all those who supported me!
bc7f11e7-5fee-435a-93c9-9857dc129f5b|0|.0
String.IsNullOrEmpty is a commonly used method for determining whether a string is null or has a zero length. But, no such method exists in the FCL for collections. A moment ago I whipped up an extension method for IEnumerable types. It's not rocket science, but I thought I would post it anyway.
public static class Extensions
{
/// <summary>
/// Determines whether the collection is null or contains no elements.
/// </summary>
/// <typeparam name="T">The IEnumerable type.</typeparam>
/// <param name="enumerable">The enumerable, which may be null or empty.</param>
/// <returns>
/// <c>true</c> if the IEnumerable is null or empty; otherwise, <c>false</c>.
/// </returns>
public static bool IsNullOrEmpty<T>(this IEnumerable<T> enumerable)
{
if (enumerable == null)
{
return true;
}
/* If this is a list, use the Count property.
* The Count property is O(1) while IEnumerable.Count() is O(N). */
var collection = enumerable as ICollection<T>;
if (collection != null)
{
return collection.Count < 1;
}
return enumerable.Any();
}
/// <summary>
/// Determines whether the collection is null or contains no elements.
/// </summary>
/// <typeparam name="T">The IEnumerable type.</typeparam>
/// <param name="collection">The collection, which may be null or empty.</param>
/// <returns>
/// <c>true</c> if the IEnumerable is null or empty; otherwise, <c>false</c>.
/// </returns>
public static bool IsNullOrEmpty<T>(this ICollection<T> collection)
{
if (collection == null)
{
return true;
}
return collection.Count < 1;
}
}
IEnumerable.Count is O(N), while List.Count is O(1), hence the test for the IList type.
5366fc86-fb02-4728-ba1c-e34a064971af|1|5.0
I arrived back in Geneva on Thursday night, after spending a couple of days in Belgium attending Techdays 10. I had a blast, and some of the highlights for me were:
- The presentation by my good friend Laurent Bugnion entitled A day in the life of a WPF/SL. Very cool.
- I had the opportunity to ask Anders Hejlsberg about the new .NET 4.0 default parameter feature.
- I attended a presentation on Moles. Looking forward to using that. One can replace any .NET property or method with a delegate!
- Scott Hanselman’s keynote on day two was just so entertaining. Loved it.
All in all, it was a terrific event.
To top it all off, I discovered my MVP award from Microsoft waiting for me when I arrived home! MVP profile
43e3d703-5fe8-4ceb-ae66-8302ee6e4b30|0|.0