Advanced C# Tips: Don’t Use unsafe for Minor Gains
The title could have also been “Don’t use unsafe code at all!” You will come to the same conclusion after reading this post, but still I gave a room for…
The title could have also been “Don’t use unsafe code at all!” You will come to the same conclusion after reading this post, but still I gave a room for…
In C#, the in parameter modifier is relatively a recent addition. It added in C# 7.2. The main point of in keyword is to pass a large value type to…
Before diving into topic, I want to begin with clarifying the terminology. Immutable data refers to data whose state cannot be modified after it has been created. Once an immutable…
In C#, understanding the difference between value types and reference types is a fundamental topic when writing efficient and performant code. The choice between using a value type (like a…
Exceptions in C# are definitely a great facility but we need to use them wisely. We should leave the least possible probabilities of throwing an exception since exceptions come with…
Bitwise operators in C# are special tools that let you work directly with the individual bits of a number’s binary representation. If you are reading this blog post, I assume…
ArrayPool<T> in C# is a very useful but a less known feature. It has been around since .NET 2.0 but has never been popular. In order to understand ArrayPool, we…
Reusing objects in C# is a strategy that aligns with the principles of efficient memory management and application performance optimization. This concept is important in environments where memory resources are…
Even though it is not a very popular C# tool, the ArraySegment<T> is quite old and it was introduced in .NET Framework 2.0, which was released in 2005. It is…
Inlining methods is a technique where the compiler replaces a method call with the actual method body’s code. While inlining can speed up your program by eliminating the overhead of…
Lazy loading and eager loading are two contrasting approaches in managing how and when data is loaded into memory in programming, particularly relevant in the context of databases, data processing,…
The readonly modifier in C# is a keyword applied to fields that should not change after the constructor for an object has completed. Using readonly indicates that the data is…
In C#, when you want to go through all the items in an array one by one, you can use either a for loop or a foreach loop. Both will…
Span<T> in C# is an innovative feature that revolutionizes how developers work with contiguous memory regions, like arrays or memory blocks. The Span is introduced in C# 7.2 and it…
Micro-optimizing refers to making small modifications to code in an attempt to improve performance, often at the expense of making the code harder to read, understand, and maintain. While it’s…
Recursive functions are a staple in many programmers’ toolkits. They allow us to solve complex problems by having a function call itself with a different set of parameters until a…
In C#, it’s common to sprinkle your code with debugging information—like console logs that help you track down bugs. However, when you’re ready to release your application to the world,…