Best of C# — 2024
- 1
- 2
- 3
- 4
Game Developers·2y
Free Game development full course
A seasoned game developer is offering a free course to teach C# and Unity, targeting aspiring game developers. The course aims to make the learning journey easier and includes regular lectures. Interested participants are invited to join by contacting the instructor on Discord.
- 5
Community Picks·2y
Dependency Injection made simple.
Dependency Injection simplifies handling dependent objects, making code more flexible and decoupled. In JavaScript, passing connection objects through constructors exemplifies this. For strongly typed languages like C# and Java, interfaces help enforce consistent structures. This approach enhances code management and testing.
- 6
Towards Dev·2y
SOLID Principles in C#
The SOLID principles are a set of five key design principles for building maintainable and flexible software architecture: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion. The post details each principle with examples in C#, providing guidelines to help keep classes focused and testable, favoring abstraction and composition over inheritance, and ensuring extensibility without modifying existing code.
- 7
InfoWorld·2y
Best practices for handling exceptions in C#
Effective exception handling is crucial for building robust applications. Key practices include deriving custom exceptions from the Exception class, handling exceptions at the highest level in the call hierarchy, using specific exceptions for clarity, employing try/catch/finally blocks for resource cleanup, and avoiding the re-throwing of exceptions to maintain stack trace integrity. Always log exceptions properly and use validation logic to minimize the need for exceptions.
- 8
Community 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.
- 9
- 10
DEV·2y
Understanding IQueryable<T> in C#
Understanding IQueryable<T> in C# is crucial for efficient data querying. This interface, integral to LINQ, supports deferred execution and expression trees, enabling optimized and flexible queries over data sources like SQL databases or in-memory collections. It allows for method chaining to build complex queries and can be extended using custom extension methods for functionality like filtering, sorting, and pagination.
- 11
This is Learning·2y
7 Open Source Projects You Should Know - C# Edition ✔️
Discover seven noteworthy open source projects developed in C#. The projects include QuestPDF for PDF generation, ShareX for screen capture, OpenRA as a real-time strategy game engine, Uno Platform for building multi-platform applications, QRCoder for generating QR codes, Windows Auto Dark Mode for theme switching, and Ryujinx, a Nintendo Switch emulator. Each project offers unique functionalities, from improving productivity to supporting game development.
- 12
Hacker News·2y
The .NET Programmer's Playground
LINQPad offers interactive querying for databases in LINQ and SQL. It generates association properties automatically, making data access simple. LINQPad supports various databases, caches intermediate results, and features a Dump method for intelligent object inspection. It supports advanced C# features, acts as a rapid coding tool, and offers functionalities such as benchmarking and Excel export. LINQPad also includes a tutorial and numerous example queries, making it easy to learn.
- 13
freeCodeCamp·2y
How To Use LINQ in C# – With Code Examples
LINQ, part of the .NET framework, allows for powerful data querying through both language-level query syntax and method syntax. This post covers various LINQ methods such as `OrderBy`, `First`, `Single`, `SingleOrDefault`, and `Select` with examples on how to apply them. It also delves into deferred execution and method chaining, demonstrating how LINQ can optimize performance and allow for more complex, readable queries. Writing defensive code to handle changes in data over time is emphasized for error prevention.
- 14
- 15
Community Picks·2y
Result Pattern
The Result Pattern provides a structured method for dealing with errors in C#. It promotes clearer code and allows for more precise control over error handling. Using the Result Pattern can improve performance compared to using exceptions, especially in situations where errors occur frequently.
- 16
- 17
Waseem .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.
- 18
ASP.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.
- 19
Waseem .NET Newsletter·2y
EP 62 : Dependency Injection Explained in .NET
Dependency injection is a programming technique in which an object receives other required objects instead of creating them internally. Benefits of dependency injection include automatic handling of object creation and disposal, easy unit testing, and adaptability to changes without affecting existing code. Dependency injection can be implemented using the singleton, transient, or scoped approach.
- 20
Milan Jovanović·2y
Improving Code Quality in C# With Static Code Analysis
Static code analysis is a vital tool for improving code quality in C# projects. It helps detect issues related to security, performance, and coding style without running the code. The post covers how to set up static code analysis using built-in Roslyn analyzers in .NET, configure properties in `Directory.Build.props`, and leverage additional tools like `SonarAnalyzer.CSharp`. The process involves treating warnings as errors and customizing rules via `.editorconfig` to create secure, maintainable, and high-quality code.
- 21
ASP.NET Blog·2y
C# 13: Explore the latest preview features
C# 13 introduces new features focusing on flexibility, performance, and enhancing everyday use. Key updates include enhancements to params collections, new lock object improvements for mutual exclusion, index operator improvements, a new escape sequence for the ESC character, and the introduction of partial properties. Additionally, there are enhancements to method group natural type determination and relaxed restrictions for ref and unsafe contexts in async methods and iterators. The preview can be tried with the latest .NET 9 and Visual Studio 2022 updates.
- 22
- 23
habr·2y
Spans in C#: Your Best Friend for Efficient Coding
Spans in C# provide a powerful way to handle memory efficiently, reducing allocations and improving performance. They allow for direct manipulation of memory regions, support safe code practices, and are stack-allocated. This guide covers their use, differences between Span<T> and ReadOnlySpan<T>, and practical examples, including JSON parsing, converting arrays, and strings to spans. Ensuring proper scope and compatibility with development environments is crucial for optimal use.
- 24
freeCodeCamp·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.
- 25
Code Maze·2y
Advanced Debugging in C#
This post delves into advanced debugging techniques in C# using Visual Studio 2022. It covers conditional breakpoints, tracepoints, hit count, and filter conditions. The post also explains how to change breakpoint locations, edit code during a debugging session, use the execution pointer, set function and dependent breakpoints, track variables with object IDs, and utilize string visualizers for viewing formatted strings.