DEV Community

Discussion on: 5 easy tips for writing C# better

Collapse
 
n3wt0n profile image
Davide 'CoderDave' Benvegnù

I agree with everything, except this:

if (yourVar is { Length: > 0 })
{
    //your code
}
Enter fullscreen mode Exit fullscreen mode

I think the other way to write code with the !string.IsNullOrEmpty(yourVar) is much clearer and easier to read.

Good code doesn't always mean the same thing, and I think writing "better" code also means having higher readability for everyone, from junior devs up.

IMHO, of course :)

Collapse
 
kasuken profile image
Emanuele Bartolesi

you know what? For me it's more easy to read this line of code.
At the beginning I agreed with you... but now I prefer the "new" version.

and of course... everyone can have different opinions