20
Writing “string.IsNullOrEmpty” using pattern matching and comparing the resulting code
(www.tabsoverspaces.com)
A community about the C# programming language
Getting started
Useful resources
IDEs and code editors
Tools
Rules
Related communities
string.IsNullOrEmpty(myStr)
has always annoyed me, why isn't it an extension method or a non-static method?myStr.IsNullOrEmpty()
just feels cleaner and more intuitive to me.myStr.IsNullOrEmpty()
feels a bit weird to me, because you have to know that it's an extension method.Otherwise it kinda looks like you might be trying to run a method of something that's possibly
null
That's the same design principle of why
ArgumentNullException.ThrowIfNull(myStr)
is not an extension method