Best of C#September 2024

  1. 1
    Article
    Avatar of communityCommunity Picks·2y

    Faster Dictionary in C#

    The .NET Base Class Library's Dictionary<TKey, TValue> offers constant time access to values, but duplicated lookups can reduce efficiency. Utilizing the TryAdd method in .NET Core 2.0 can prevent duplicate lookups and boost performance. Additionally, .NET 6 introduced methods in System.Runtime.InteropServices.CollectionsMarshal to address duplicate lookup scenarios using managed pointers. These methods, alongside managed pointers and the ref keyword, can significantly speed up dictionary operations, particularly with structs and large structures. However, it's crucial to handle managed pointers cautiously to avoid potential issues with dictionary reorganization.

  2. 2
    Article
    Avatar of game_developersGame Developers·2y

    Starting game development

    A game development enthusiast shares their experience of learning Python and Pygame to create a small Mario Bros clone. They now seek recommendations on transitioning to C# and Unity for further game development projects.

  3. 3
    Article
    Avatar of mwaseemzakirWaseem .NET Newsletter·2y

    EP 66 : Clean Code Tips for .NET Developers - Part I

    This post provides clean code tips for .NET developers, focusing on giving meaningful names, avoiding null returns, keeping class and method sizes small, not reinventing the wheel, and using appropriate tools or IDEs. It also offers practical examples and suggestions for better coding practices in .NET projects.

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

    Performance Improvements in .NET 9

    Exciting performance improvements are packed into .NET 9, making it the best and fastest release so far. More than 7,500 pull requests, with a significant focus on performance, contribute to this release. Key highlights include dynamic profile-guided optimization (PGO), enhanced just-in-time (JIT) compiler optimizations, refined tier 0 compilation, loop optimizations, and reductions in bounds checking overheads. These changes collectively enhance runtime efficiency, memory management, and overall application speed.

  5. 5
    Video
    Avatar of nickchapsasNick Chapsas·2y

    Stop Using FirstOrDefault in .NET! | Code Cop #021

    Nick explains why using the Find method over FirstOrDefault in .NET lists can be a misleading practice. He highlights performance comparisons and how optimizations in .NET 9 make FirstOrDefault faster, emphasizing the importance of understanding such nuances to avoid harming code and performance.

  6. 6
    Article
    Avatar of milanjovanovicMilan Jovanović·2y

    Refit in .NET: Building Robust API Clients in C#

    Refit is a type-safe REST library for .NET that simplifies interacting with APIs by turning them into interfaces. This reduces boilerplate code, handles serialization automatically, and makes API calls more readable and maintainable. The post provides steps to set up Refit, including installing necessary packages, defining an interface for API calls, configuring dependencies, and handling query parameters, headers, and authentication. Refit also offers options for JSON serialization and more control over HTTP responses.

  7. 7
    Article
    Avatar of vikingsoftwareViking Software·2y

    Battle of the Backends

    This post discusses the pros and cons of various programming languages for web backend development, including Rust, Go, C#, and Python. The author highlights Rust's advantages in dependency handling but notes its ecosystem's immaturity. Go is praised for its environment, but its stagnation in updates is a concern. C# is appreciated for its ease of development but criticized for occasional performance issues. Python is deemed suitable only if there's existing developer expertise. A strong stance is taken against using Javascript for backends.

  8. 8
    Article
    Avatar of codemazeCode Maze·2y

    Mediator Design Pattern in C#

    The Mediator Design Pattern promotes loose coupling by centralizing communication between components. Instead of interacting directly, components relay messages through a mediator that decides which component to engage next. This approach reduces chaotic inter-dependencies, effectively addresses workflow management in complex systems, and makes the interactions easier to maintain. However, it introduces an extra layer of complexity and may lead to performance overhead and maintenance challenges if not carefully designed.

  9. 9
    Article
    Avatar of codemazeCode Maze·2y

    StringValues in ASP.NET Core

    StringValues is a specialized type in ASP.NET Core designed to efficiently handle collections of strings, especially useful for scenarios involving HTTP headers, query strings, and form data. Unlike naive implementations using arrays or older solutions like NameValueCollection, StringValues minimizes memory allocations by using a single internal object to represent multiple strings. This enhances performance and scalability, making it ideal for high-traffic web applications.

  10. 10
    Video
    Avatar of nickchapsasNick Chapsas·2y

    TUnit: The Future of Testing in .NET

    TUnit is a new testing library for .NET that offers significant modernization and control for unit and integration testing. It leverages source generation for faster test execution and provides advanced features like async assertions, hooks for setup and teardown, multi-threaded test execution, and retry mechanisms for flaky tests. The library is highly configurable and supports dependency injection and compile-time checks, which enhance the robustness and flexibility of tests. The post discusses these features in detail using a simple calculator test as an example and encourages readers to try out TUnit and provide feedback.

  11. 11
    Article
    Avatar of csharpcornerC# Corner·2y

    How C# Manages Memory Automatically

    C# handles memory management automatically through a process called garbage collection, which manages the allocation and deallocation of memory. The garbage collector uses techniques like reference counting and generation-based collection to identify and reclaim memory from objects that are no longer in use. Developers can use constructs such as the 'using' statement to ensure proper disposal of objects, which helps in managing resources efficiently and avoiding memory leaks.

  12. 12
    Video
    Avatar of youtubeYouTube·2y

    .NET and C# are in trouble. Here is what I'd do.

    The current rapid release cycle of .NET and C# is causing exhaustion among developers, who struggle to keep up with frequent changes. This post discusses issues with the release schedule, lack of built-in administrative tools, and limited long-term support, comparing the framework’s approach to others like Django and Node.js. Emphasizing that extending support periods and addressing these gaps could help in better adoption of .NET and C#.