Best of C#November 2024

  1. 1
    Article
    Avatar of freecodecampfreeCodeCamp·2y

    How to Benchmark Your Code in C#

    Learn how to benchmark and optimize your C# code using BenchmarkDotNet, a powerful library for accurate performance measurements. Discover why Stopwatch is not reliable for detailed benchmarking, understand key metrics like mean, error, and standard deviation, and explore how to measure memory allocation and garbage collection impacts. This guide also explains running benchmarks across different .NET frameworks and inputs for comprehensive performance insights.

  2. 2
    Video
    Avatar of nickchapsasNick Chapsas·2y

    Stop Using AutoMapper in .NET

    The post discusses the drawbacks of using AutoMapper and other mapping libraries in .NET, advocating for manual mapping instead. It highlights issues such as the introduction of runtime errors, complexity, and debugging difficulties when using these libraries. The author suggests using simple extension methods for mapping and emphasizes the importance of maintaining control over the code. Alternatives like compile-time libraries are mentioned but manual mapping is preferred for its simplicity and reliability.

  3. 3
    Video
    Avatar of nickchapsasNick Chapsas·2y

    Everything New Added in .NET 9 with Examples

    Nick introduces various new features of .NET 9, focusing on practical implementations that developers will find useful. Key features include feature switching for managing feature flags, improvements in LINQ for simplified code, and hybrid cache for combining memory and distributed caching under a common API. Additionally, there are significant enhancements in handling spans and new functionalities like ordered GUIDs. The video provides detailed examples and real-world applications of these features.

  4. 4
    Article
    Avatar of elmahelmah.io·2y

    Exploring C# Records and Their Use Cases

    C# records, introduced in C# 9.0, provide immutable data types and value-based equality, offering a concise syntax compared to traditional classes. Records are especially useful for Data Transfer Objects (DTOs), immutable types, snapshots, and data versioning, enhancing testing and debugging with automatic `ToString()` methods and value-based equality.

  5. 5
    Article
    Avatar of codemazeCode Maze·2y

    How to Use Pointers in C#

    Pointers in C# allow direct memory access by holding the memory address of another variable, bypassing .NET's garbage collection. This guide covers their syntax and usage in unsafe code blocks, demonstrates creating pointers to variables, and using them as method arguments. Key considerations include using the fixed statement to pin objects in memory and prevent garbage collector interference, and understanding the risks and benefits of integrating pointers in .NET projects.

  6. 6
    Video
    Avatar of nickchapsasNick Chapsas·2y

    The Best Way to Work with Units in .NET

    Nick demonstrates how the Units.Net library can simplify working with units of measurement in .NET applications. He outlines how the library allows easy conversions between various units such as Celsius, Fahrenheit, and Kelvin without complex code. The library also supports serialization and different cultures, making it extremely versatile for enterprise and domain-specific development.

  7. 7
    Article
    Avatar of telerikTelerik·2y

    Getting Started with Domain-Driven Design in ASP.NET Core

    Domain-driven design (DDD) aligns code structure with business logic to address complex problems. This guide introduces the basics of DDD and steps for creating a microservice using ASP.NET Core, focusing on strategic and tactical design. It covers setting up various layers, including domain, infrastructure, and application, and provides a practical example of a commission processing module, complete with code snippets and explanations.

  8. 8
    Article
    Avatar of aspnetASP.NET Blog·2y

    Get Ready for .NET Conf 2024!

    Get ready for .NET Conf 2024, a free three-day virtual conference from November 12-14, showcasing the latest in .NET. Highlights include the release of .NET 9, specialized sessions from global experts, continuous broadcasts, and exclusive digital swag. Don't miss live presentations by the .NET team and the chance to win valuable prizes.

  9. 9
    Article
    Avatar of elmahelmah.io·1y

    C# 13 Features: What's New and How to Use It

    C# 13, introduced with .NET 9, brings numerous enhancements to improve developer productivity and code quality. Key features include enhanced params scope, new lock type and semantics, a new escape sequence for the ESCAPE character, implicit index access, method group natural type optimization, and more extensive partial members such as properties and indexers. These updates aim to streamline coding practices, improve performance, and enhance readability.

  10. 10
    Video
    Avatar of communityCommunity Picks·2y

    Learn C# Beginner to Advanced FREE Tutorial Course! [12 HOURS - 2024]

  11. 11
    Article
    Avatar of collectionsCollections·2y

    Enhancements and New Features in C# 13

    C# 13 introduces several enhancements to make coding more efficient and organized. Key features include the use of 'params' with various collection types, support for partial properties, a new efficient synchronization method, and access to backing fields of auto-properties with the 'field' keyword. Additionally, 'ref' structs can now implement interfaces and be used with generics, improving performance in specific scenarios.

  12. 12
    Article
    Avatar of codemazeCode Maze·2y

    Early Binding and Late Binding in C#

    Method binding in C# can occur at compile-time (early binding) or runtime (late binding). Early binding optimizes performance and ensures type safety by resolving method calls during compilation. Late binding offers flexibility by determining methods at runtime, making it suitable for scenarios requiring adaptability despite a performance trade-off. Knowing when to use each method is crucial depending on whether the application needs high performance or dynamic type handling.

  13. 13
    Article
    Avatar of aspnetASP.NET Blog·2y

    Calling methods is easier and faster with C# 13 params collections

    C# 13 introduces a feature that allows `params` to be any of the collections supported by collection expressions, rather than just arrays. This enhancement builds on collection expressions introduced in C# 12, enabling simpler and more efficient method calls. This change optimizes performance by allowing the compiler to use stack space and special high-performance types for collection interfaces. Method overloading with `params` collections is also enhanced, providing more flexibility and better performance in applications.

  14. 14
    Video
    Avatar of nickchapsasNick Chapsas·1y

    When You Shouldn't Use Await Async in .NET

    The post discusses scenarios where synchronous methods can outperform asynchronous ones in .NET, particularly with large datasets and very long strings in Entity Framework Core. A demonstration using a Docker-hosted SQL Server shows the sync version running faster and using less memory than the async version. A profiling tool, Ultra, is used to analyze and visualize the performance. Although a specific bug impacts async performance in some cases, async methods generally scale better and should typically be preferred for their non-blocking nature.

  15. 15
    Article
    Avatar of wearedotnetWe Are .NET·1y

    Learning AI function calling in C# with Llama 3.2 SLM and Ollama running on your machine

    Learn how to integrate AI function calling into your C# applications using Llama 3.2 SLM and Ollama. This guide explains core concepts, setting up the environment, and provides a practical example using a C# source generator. Enhance your projects by enabling AI models to interact with external tools or APIs, performing tasks that require real-time data or specific computations.

  16. 16
    Article
    Avatar of itnextITNEXT·2y

    Deep Dive into .NET Hosted Services

    The post provides an in-depth exploration of .NET hosted services, focusing on the `BackgroundService` class and its internal workings, including its interaction with the `Host` class. Key aspects covered include the `StartAsync` and `StopAsync` methods for managing background tasks, cancellation mechanisms, and service lifecycle events through the `IHostApplicationLifetime` interface. The importance of registration order for optimizing startup and shutdown behaviors is also discussed.