Acceptable name for extension method that accept null

Posted by GaryX on Stack Overflow See other posts from Stack Overflow or by GaryX
Published on 2011-02-28T23:06:00Z Indexed on 2011/02/28 23:24 UTC
Read the original article Hit count: 161

Filed under:
|

Hi,

I really don't like to call String.IsNullOrEmpty(str). That makes me need to think "String" class first, then call it on the object "str".

I like to call str.IsNullOrEmpty(), which doesn't need me to think "String" class.

The problem is that extension method accept null instance to call on, which is not the usual case when you call a normal method.

My question what do you think will be a convetion name for extension methods that accept null?

  1. For string, that is easy, "IsNullOrEmpty()" (anything that contains "IsNull") sounds good for me.

  2. For others, like GetDisplayName(), do we name it as "NullOrGetDisplayName" ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET