Category: .NET

  • The Art of Low-Level Memory: Mastering Span, Memory, and ref struct

    The Art of Low-Level Memory: Mastering Span, Memory, and ref struct

    This article introduces a powerful, modern C# toolkit designed to bypass traffic jams by writing allocation-free code. We will explore Span<T>, a type-safe “window” into existing memory that lets you parse and process data without creating copies. We’ll then cover its essential, heap-friendly counterpart, Memory<T>, which is crucial for asynchronous programming. Finally, we’ll dive into creating your own ref struct types to build custom, high-speed utilities that operate entirely on the stack. Throughout this guide, we will use the practical context of our car rental application to demonstrate how these features can be used to optimize critical code paths, delivering… Go to Post

  • The Essential Guide to Basic Data Types in C#: A Journey Through the Foundations

    The Essential Guide to Basic Data Types in C#: A Journey Through the Foundations

    When diving into a new programming language, understanding its basic data types is like learning the alphabet before you write a novel. In C#, data types form the bedrock of how you work with data—whether it’s numbers, text, or more complex structures. But unlike some languages that prefer to keep things ambiguous (cough JavaScript cough), C# is strongly typed. This means every variable you declare has a specific data type, and the compiler insists you stick to it. No shortcuts. No funny business. It’s like having a very strict grammar teacher who loves semicolons. So, let’s begin our descent into the type system… Go to Post

  • C# Arrays Explained: Types, Features, and Operations

    C# Arrays Explained: Types, Features, and Operations

    Arrays are the workhorses of programming and, in C#, they play a pivotal role in managing collections of data efficiently. Understanding how to declare, manipulate, and apply them is key to unlocking the full potential of the language. What is an Array in C#? In C#, an array is a collection of elements of the same type, stored in contiguous memory locations. Arrays allow you to store and manage multiple values under a single variable name, making data handling more efficient. Arrays have the following key Characteristics: Declaring Arrays Single-Dimensional Arrays The simplest form of an array can be declared and initialised as… Go to Post