Best of C#October 2024

  1. 1
    Article
    Avatar of communityCommunity Picks·2y

    What's new in C# 13: overview

    C# 13 introduces several noteworthy updates including object initialization using 'from the end' index, partial properties and indexers, support for collections with the 'params' modifier, and a new OverloadResolutionPriorityAttribute to prioritize method overloads. Other enhancements include a new Lock class for better thread synchronization, a new escape sequence character '\e', improvements in method group natural type handling, and expanded usage of 'ref struct' in async and iterator methods. These changes aim to simplify code readability and offer more robust control for developers.

  2. 2
    Article
    Avatar of advanceddotnetAdvanced .NET·2y

    How did you guys get into C#/.NET? Do you think it is a solid option for most projects?

    The author shares their journey of learning C# through Unity and continuing with .NET for other applications. With experience in multiple programming languages, the author believes C# offers an optimal balance of simplicity, safety, and speed. The introduction of top-level statements has made C# more appealing for scripting tasks previously handled with Python.

  3. 3
    Article
    Avatar of hnHacker News·2y

    .NET 9.0 LINQ Performance Improvements

    NET 9.0 offers significant performance improvements to LINQ, particularly through the use of TryGetSpan() which enhances iteration over arrays and lists. These optimizations include the introduction of specialized iterators for common LINQ call chains, leading to more efficient execution of methods like Count(), First(), and Last(). Additionally, SIMD is utilized for operations like summing integers, and the overhead for empty sequence enumeration is reduced. Understanding and implementing these changes can yield noticeable performance gains in your code.

  4. 4
    Article
    Avatar of infoworldInfoWorld·2y

    Microsoft releases official OpenAI library for .NET

    Microsoft has released an official OpenAI library for .NET, offering full REST API support and compatibility with flagship models like GPT-4o. Available via NuGet, the library includes sync/async APIs, streaming completions, and .NET Standard 2.0 compatibility. It supports extensibility and aims to ensure seamless integration with OpenAI and Azure OpenAI services.

  5. 5
    Article
    Avatar of freecodecampfreeCodeCamp·2y

    How to Use Conditional Statements in C#: If, Switch, and More Explained with Example Code

    This post covers various conditional coding mechanisms in C# including if/else statements, ternary operators, and switch-case statements. It explains their syntaxes, provides example code, and discusses performance considerations and appropriate use cases for each method. Additionally, it explores switch-case expressions introduced in C# 8 and benchmarks the performance of different conditional techniques.

  6. 6
    Article
    Avatar of freecoursesFREE COURSES!·2y

    100% FREE - Unity C# Game Development for Absolute Beginners - Build a First Person Shooter Player from Scratch

    Learn the basics of Unity and C# for game development through this free course. The course guides absolute beginners in creating a first-person shooter player from scratch.

  7. 7
    Article
    Avatar of dotnet.NET Blog·2y

    .NET 9 Release Candidate 2 is now available!

    The .NET 9 Release Candidate 2 is now available with enhanced performance, stability, and optimizations ahead of its general availability release in November. This version includes updates to libraries, runtime, SDK, ASP.NET Core, and .NET MAUI. Developers are encouraged to try out this latest release and provide feedback. Key resources such as release notes, installation guides, and GitHub discussion links are provided.

  8. 8
    Article
    Avatar of lemireDaniel Lemire·2y

    How fast can you parse a CSV file in C#? – Daniel Lemire's blog

    Explores different methods of parsing large CSV files in C#, comparing the performance of CsvHelper and NReco.Csv libraries, and demonstrating a low-level approach that significantly boosts parsing speed on a .NET 9 system with an Apple M2 processor.

  9. 9
    Article
    Avatar of codemazeCode Maze·2y

    How to Get an Instance of IServiceProvider in .NET

    In modern .NET applications, understanding how to obtain and use an instance of IServiceProvider is crucial for effective dependency injection, which promotes loose coupling and enhances maintainability. This post outlines various methods to get an instance of IServiceProvider, including during application startup, within service classes, controllers, and unit tests. It also discusses best practices and common pitfalls, emphasizing the importance of proper service lifecycle management and the benefits of constructor injection over direct service resolution.

  10. 10
    Video
    Avatar of nickchapsasNick Chapsas·2y

    How to Measure Time Correctly in .NET

    Nick explains the correct method to measure elapsed time in .NET applications, emphasizing that using DateTime.UtcNow is incorrect due to performance issues. He demonstrates how to implement accurate time measurement using the Stopwatch class and introduces the more efficient Stopwatch.GetTimestamp method available in .NET 7. This method avoids unnecessary allocations and provides precise time measurements by interacting directly with the operating system's low-level functions.

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

    How Select and SelectMany Works in C#

    Select in LINQ projects each element of a sequence into a new form, transforming elements in a collection. SelectMany projects each element to an IEnumerable<T> and flattens the resulting sequences into one, useful for collections of collections.

  12. 12
    Article
    Avatar of andrewlock.NET Escapades·2y

    Replacing Exceptions-as-flow-control with the result pattern

    The post discusses the inefficiencies of using exceptions for flow control in .NET applications and introduces the result pattern as a more efficient alternative. It starts with a simple API implementation without error handling, adds exceptions for common error cases, and then replaces these exceptions with a Result<T> type to demonstrate the result pattern. However, the initial implementation of the result pattern is cumbersome, leading to the next post in the series where the pattern will be simplified further.

  13. 13
    Article
    Avatar of andrewlock.NET Escapades·2y

    Is the result pattern worth it?

    The post concludes a series discussing the use of the result pattern over exceptions for flow control in C#. It highlights how LINQ can simplify nested lambda methods, improving readability. The discussion contrasts heavy and lightweight versions of the result pattern with perspectives from industry experts. It addresses the argument for substituting exceptions with the result pattern and presents LINQ as a readable but complex alternative for error handling. The post suggests that while LINQ can simplify code, developers must evaluate whether its complexity is justified in their specific use cases.

  14. 14
    Article
    Avatar of codemazeCode Maze·2y

    Publish MediatR Notifications in Parallel

    Explore how to publish MediatR notifications in parallel, starting with the default sequential publishing strategy. Learn how to implement parallel publishing using newer MediatR features, create test notifications and handlers, and configure dependency injection. Understand the pros and cons of parallel publishing, including performance benefits and potential pitfalls like ThreadPool starvation and race conditions.