this post was submitted on 14 May 2024
20 points (100.0% liked)

C Sharp

1707 readers
1 users here now

A community about the C# programming language

Getting started

Useful resources

IDEs and code editors

Tools

Rules

Related communities

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] Rogue@feddit.uk 4 points 1 year ago (3 children)

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.

[–] RonSijm@programming.dev 4 points 1 year ago

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

load more comments (2 replies)