Acceptable name for extension method that accept null
- by GaryX
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?
For string, that is easy, "IsNullOrEmpty()" (anything that contains "IsNull") sounds good for me.
For others, like GetDisplayName(), do we name it as "NullOrGetDisplayName" ?