Simplify your functions #csharp #shorts

preview_player
Показать описание
How to simplify functions in C#
Want to learn more about C#? 🔽

Check out my learning series😊

Or project series 😍

💻 Community Discord server
When you join the server, you can get your own personal help channel for FREE where you can post anything you're stuck with and I will help you 😊

☕ Buy me a Coffee

📣 Socials
Рекомендации по теме
Комментарии
Автор

make it a one liner with a lambda expression
static bool IsEven(int number) => number % 2 == 0 ;

awwad
Автор

But is there even a need for one liners ? Isn't readability more important than brevity ?

pierrehamelin
Автор

Why is there an else statement? If you already return in the first conditional you don't need another one. Is it for educational purposes? And I also agree that a ternary expression would be appropriate as this function would never change.

ikroeber
Автор

"Functions shouldn't be wrote like this" I agree, that brance style is horrible. P.s. it's "written" not "wrote".

He wrote. It is written.

robertsandiford