DEV Community

Cover image for 50 C# (Advanced) Optimization Performance Tips🔥

50 C# (Advanced) Optimization Performance Tips🔥

ByteHide on May 26, 2023

As an experienced C# developer, you’re always looking for ways to improve your application’s performance. Good news! You’ve come to the right place...
Collapse
 
canro91 profile image
Cesar Aguirre

I think you actually meant Task vs ValueTask...

Collapse
 
bytehide profile image
ByteHide

Fixed! Thanks for the notice😅😁

Collapse
 
deexter profile image
deexter

Top article

Collapse
 
bytehide profile image
ByteHide

Great that you like it!

Collapse
 
suzany profile image
Laura Suzany

Wow! It's amazing. Thanks for sharing these tips <3

Collapse
 
rezanouri profile image
reza nouri

Great
Thanks ❤️

Collapse
 
bytehide profile image
ByteHide

Thanks to you for taking the time to read it!

Collapse
 
ezrankings profile image
Mansi Rana

Thanks for sharing This amazing article.

Collapse
 
bytehide profile image
ByteHide

A lot of thanks Mansi! :D

Collapse
 
michalispapamichael profile image
Michalis Papamichael

Great Article!

Collapse
 
bytehide profile image
ByteHide

Thanks!

Collapse
 
j0nimost profile image
John Nyingi

you missed a really good one IAsyncEnumerable it's powerful

Collapse
 
bytehide profile image
ByteHide

Wow, you are so right😥! Noted and thank you very much for the comment!

Collapse
 
ant_f_dev profile image
Anthony Fung

This is a comprehensive list of great tips - thanks for sharing.

Collapse
 
bytehide profile image
ByteHide

Thank you! If you have any tips you would like to share, we'd love to hear from you! All this is open-source 😎

Collapse
 
lico profile image
SeongKuk Han

Awesome 🔥.
I'm not into C# now, I'm mainly working with js, but there are lots of things I could learn and can apply for me such as Avoid premature optimizations, importance of caching data, avoid using exceptions for flow control, utilize generics and custom interfaces to avoid boxing...
It was also interesting seeing what what they think as important things in C# and the way it works, especially about parallelism and features and effort to work with multi-threaded system.

Collapse
 
slavius profile image
Slavius

I just want to warn everyone that many of the tips are very opinionated and some are just blatantly copy/pasted without really understanding the problem or explaining the context in which they are appropriate while making them risky in your code.
Few examples are ConfigureAwait(false) and use of stackalloc instead of e.g. Span<T>.

Collapse
 
sbenzenko profile image
Sergey Benzenko • Edited

Could you please show the source of information that you used for the example where you used LINQ AsParallel() within Parallel.ForEach?
I could not find this kind of usages of AsParallel anywhere. And in the documentation AsParallel is used for the whole different purpose entirely (not for thread safety within Parallel.ForEach).

Thank you in advance.

Collapse
 
lidiaaadotnet profile image
lidiaaadotnet

Now that's a real top😍

Collapse
 
dmitryeremenko715 profile image
dmitryeremenko715

Hello, I'm interested in finding a partner to work on .NET projects with. I noticed that you're also interested in this space and wanted to reach out to see if you might be interested in discussing the possibility of working together.

I value clear communication and collaboration, and I'm committed to finding a good fit for both of us. Let me know if you're open to discussing this further, and we can set up a time to chat more.

Telegram: @krumfi_cto
Gmail: dmitryeremenko715@gmail.com

Looking forward to hearing from you soon.
Best regards,
Dmitry

Collapse
 
chamacr profile image
ChamaCR

Awesome tips, thanks!

Collapse
 
rafo profile image
Rafael Osipov

Thank you for sharing. It is really valuable information here.

Collapse
 
ghadzhigeorgiev profile image
Georgi Hadzhigeorgiev

Great one, cheers!

Collapse
 
trungnguyen1697 profile image
Trung Nguyen Thanh

Thanks for sharing

Collapse
 
naidenpetrov00 profile image
Naiden Nikolaev Petrov

Great article thank you