Extension methods on a null object instance – something you did not know

Posted by nmarun on ASP.net Weblogs See other posts from ASP.net Weblogs or by nmarun
Published on Tue, 28 Jun 2011 03:56:46 GMT Indexed on 2011/06/28 8:23 UTC
Read the original article Hit count: 230

Filed under:
|
|
Extension methods gave developers with a lot of bandwidth to do interesting (read ‘cool’) things. But there are a couple of things that we need to be aware of while using these extension methods. I have a StringUtil class that defines two extension methods: 1: public static class StringUtils 2: { 3: public static string Left( this string arg, int leftCharCount) 4: { 5: if (arg == null ) 6: { 7: throw new ArgumentNullException( "arg" ); 8: } 9: return arg.Substring(0, leftCharCount); 10...(read more)

© ASP.net Weblogs or respective owner

Related posts about c#

Related posts about LINQ