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

C Sharp

1510 readers
4 users here now

A community about the C# programming language

Getting started

Useful resources

IDEs and code editors

Tools

Rules

Related communities

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] JakenVeina@lemm.ee 4 points 4 months ago (1 children)

The usual convention is to have extension methods behave like regular methods, I.E. don't allow them to accept nulls. When looking at foo.Bar(); it's better if I can just intuit that foo can't be null because you're not supposed to be able to invoke the . operator on null.

Of course, I'm entirely guilty of breaking this rule myself. cough Shoudly cough FluentAssertions cough

[–] Rogue 2 points 4 months ago* (last edited 4 months ago)

I've always used the Nullable context so typically I'm just using string.IsNullOrEmpty to determine empty strings, I'm already confident null isn't leaking. But your explanation does make sense.

I'm now wondering why I've never just used myStr != ""