Fading Coder

One Final Commit for the Last Sprint

C# Threading Fundamentals: Mastering System.Threading.Thread

Instantiating and Launching Workers Threads execute concurrently with the main application flow. By default, a newly created thread begins execution immediately upon calling Start(), allowing it to run in parallel with the primary process. using static System.Console; using static System.Threading.T...

Implementing Thread-Safe Collections in C# for Concurrent Programming

The System.Collections.Concurrent namespace provides data structures designed for multi-threaded scenarios, offering scalability and thread safety while minimizing locking. These collections are essential for efficient parallel programming. ConcurrentQueue ConcurrentQueue implements a thread-safe fi...

Common Pitfall: Why DateTime.Now Returns an Incorrect Past Date

When validating a user's date of birth with FluentValidation, comparing the input against DateTime.Now.Date can produce unexpected results: an error may incorrectly state that the input date (e.g. 2020-07-06) cannot be after the current date, even when the actual current date is 2020-07-08, and the...

Understanding the ref and out Keywords for Parameter Passing in C#

In C#, the ref and out keywords are used for parameter passing, enabling a method to modify the values of variables passed to it. However, they follow different rules and are suited for distinct scenarios. ref Keyword ref indicates pass-by-reference. Modifications to the parameter within the method...

Implementing Undo/Redo Functionality with the Generic Stack in C#

The .NET framework includes various generic collections, such as Stack<T> for last-in-first-out operations, Queue<T> for first-in-first-out, List<T> for ordered and indexed elements, LinkedList<T> for doubly linked lists without indexing, and ISet<T> implementations lik...

Building a C# Remote Directory Explorer with Telegram Integration

System Architecture The solution consists of two distinct C# applications: a Controller application running on the local machine, and a Bot agent executing on the remote target machine. The Controller issues commands serialized as JSON, transmits them through the Telegram cloud, and waits for the Bo...

Essential Visual Studio 2022 Extensions for Productivity and Code Quality

C# Method Signature Generation Quickly scaffold method definitions by typing a shortcut keyword followed by the Tab key. method: Standard method imethod: Interface method (lacks implementation body) vmethod: Virtual method smethod: Static method xmethod: Extension method amethod: Asynchronous method...

Streaming Excel Files from ASP.NET to the Client Browser

Directly transmittign an Excel workbook from an ASP.NET backend to a web client involves transforming object collections into tabular data, serializing the output to a memory buffer, and configuring the apropriate HTTP respnose headers. public void ExportCollectionAsExcel<T>(IEnumerable<T&g...

Practical C# Syntactic Features for Cleaner, More Readable Code

C# syntactic features refer to a set of language capabilities designed to reduce boilerplate code and improve code legibility. All these features are compiled down to lower-level runtime-compatible code during build, while offering far more intuitive and concise syntax for developers. Expression-Bod...

Method Definitions and Usage in C#

A method is a named block of code that encapsulates a set of instructions to perform a specific task. Programs are structured using methods to promote code reuse and organization. Every C# application contains at least one class with a Main method, which serves as the entry point. To utilize a metho...