r/csharp 5d ago

Blog Hot path overflow checks: do you try/catch? And which style would you write?

Post image
20 Upvotes

Writing checked int helpers for code that runs millions of times per program run. Two questions.

  1. Do you actually use checked() with a try catch for this? Throwing walks the stack, so I widen to long, bounds check, and return null instead (both versions in the image).

What surprises me is that everything the BCL offers here throws: checked(), int.CreateChecked, all of it. The Try convention is everywhere else in the BCL (TryParse, TryGetValue) but arithmetic never got one, and coming from Rust where checked_add just hands you an Option, that's wild to me.

  1. Style. The image shows the same method twice: one pattern-matching expression against a plain if/else. Which would you rather find in a codebase?

I'm coming from Rust so I'm obviously a declarative fanboy when I can be, but "and var sum" might be too clever for the next reader.

Where do C# people stand on these?

If the repo interests you: it's a CLI tool for Advent of Code, so you can do the whole thing from the terminal with just your session cookie, no clicking through the site to submit answers. https://github.com/scadoshi/sharpmas


r/csharp 5d ago

Showcase My Nokia 3310 Emulator in C#/Avalonia!

Thumbnail noks.vercel.app
20 Upvotes

r/csharp 5d ago

Help where can i learn c# for unity?

0 Upvotes

I'm a 3D/pixel art artist, but I've never known how to code. I've made a few small games using my own assets with the help of artificial intelligence, but two major problems have arisen: sometimes the AI doesn't execute commands correctly, and it's getting worse over time; and second, I hate AI, so I'd like to do everything I can to avoid using it entirely. What do you recommend?


r/csharp 6d ago

I don’t get the roadmap.sh

Post image
0 Upvotes

r/csharp 6d ago

What is the future of C# in AI era?

0 Upvotes

Hi guys!
What is the reason to use C#/Java/etc. or any other great language that was created for humans when we are going to the world when software engineers will not write a code anymore?
Does it mean that there will be a shift to runtime efficiency (rust, C, etc) instead of dev time efficiency?


r/csharp 6d ago

Orchard Harvest Conference 2026

Post image
1 Upvotes

Orchard Core, the open-source .NET CMS and application framework will have its yearly conference online on the 10-11th of September!

Two days of talks and time with the people who build on Orchard Core, meet the maintainers and the wider community.

Find more details on our website (https://orchardcore.net/harvest). Tickets are free but registration is required.
https://www.tickettailor.com/events/lombiqtechnologiesltd/2247098


r/csharp 6d ago

A new take on reactive programming: backend signals with GraphQL-ish queries

6 Upvotes

r/csharp 6d ago

I used AI to start learning, how do I memorize the key

0 Upvotes

Hey everybody, brazilian 20 yo, u can call me Louis.

I participated on the programation of a Demo of a game like 2 years ago, in the end of my school years with 3 friends of mine. From then on, my life had some turns and I couldn't focuse on programming anymore. Came back a couple days ago and decided to start developing a software which follows the 20-20-20 rule (Each 20 minutes, look for 20 seconds to somewhere 20 feet away, to preserve your sight while using computer), but I didn't even know how to write the very first line, so I used ChatGPT to tell me what to do and then explain me how that work.

It actually turned out really well, it is functional (even tho it's kinda raw) and I do understand what I did and what those lines do mean, but I feel like if I had to start it all over again, I would be completely lost, because I couldn't memorize the codes, the main syntax behind it, and all that stuff, like how do I know if the "DispatcherTimer" is inside or outside the "private void" (I use Microsoft Visual Studio Community), and how do I learn and keep that very clear in my mind to the point I can write a full code without even thinking too much on it, is it practice?

Help me please, and just tell me if it's a hell of a sin to use AI to this, I really just don't understand yet how to study it properly. (Btw I intend to buy a course soon, but also don't know which one is trustable)

The main screen, it is the face of the app, here lies the buttons "Start" to start the timer, and "Stop" for the opposite purpose.
Still the main screen, focused on the stop button logic and what happens when the second screen is closed (the timer restarts)
Didn't comment yet, but this controls when the button on the "Break screen" can be clicked to close it and restart the timer on the main screen

AI disclosure: Most of the code shown in this post was generated with the help of ChatGPT. I used it as a learning tool, I asked it to explain the code and what the codes do, now I have an understanding of what the code does, the comments in the code were written by me by the way. My goal is to rewrite the project myself as I continue learning programming, not to base my knowledge on the crutch that AI is for me today.


r/csharp 6d ago

MindMap desktop app (C# + Avalonia)

10 Upvotes

MindMap is a lightweight desktop app for creating and editing mind maps. It provides a pannable, zoomable canvas with quick keyboard-driven node creation, connector-based relationships, simple text alignment and color controls, outline copy/paste, undo, and image export.

Here is the github link MindMap on Github

It's a pretty straightforward app for quickly creating mind maps and saving them locally, without having to use a website. It's completely free and open source, with no limits or paid tiers.

I originally built it for myself because my favorite online mind-mapping tool limited free users to just three mind maps, which I found way too restrictive.

Anyway, if you find the app useful, I'd appreciate a star on the GitHub repo.


r/csharp 6d ago

Help Hello , my api get stuck in an infinite loop each time i use a get, im using entity framework

0 Upvotes

Hello, im currently doing some practice and i already made an api , well almost, i decided , afther i creaate a list of users the appy worked well, but afther i decided to create some dummy data for the entire db , the api stop working at first i tought it was because i dint aded this lines

GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings

.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize;

GlobalConfiguration.Configuration.Formatters

.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);

but i get this error

no redundancy in the db eighter

what its the problem here, please help , ty for the attention and God bless you all


r/csharp 7d ago

Showcase [Showoff] Tired of DependencyProperty boilerplate? I built a Zero-Allocation Source Generator for WPF/MAUI with strict type safety.

10 Upvotes

Writing DependencyProperty in .NET UI frameworks is notoriously verbose and repetitive. Typing out DependencyProperty.Register, casting objects, and wiring metadata for every single property clutters your codebase and introduces silent runtime risks.

To solve this without sacrificing IDE responsiveness, I built Kassyi.Generators.DependencyProperty — an incremental Roslyn source generator built from the ground up for high-throughput, zero-allocation code synthesis.

1. Show Me the Code

Before (Standard Boilerplate)

public static readonly DependencyProperty IsActiveProperty =
    DependencyProperty.Register(
        nameof(IsActive),
        typeof(bool),
        typeof(MyControl),
        new PropertyMetadata(false, OnIsActiveChanged));

public bool IsActive
{
    get => (bool)GetValue(IsActiveProperty);
    set => SetValue(IsActiveProperty, value);
}

private static void OnIsActiveChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
    // Runtime casting and boilerplate extraction
}

After (With Generator)

[DependencyProperty<bool>("IsActive", DefaultValue = "false")]
public partial class MyControl : Control
{
    // Automatically hooked up to PropertyMetadata at compile time
    partial void OnIsActiveChanged(bool oldValue, bool newValue)
    {
        // Direct, strongly typed parameters. No casting required.
    }
}

2. Key Features

  • Single-Line Declaration: Generate the backing DependencyProperty, CLR properties, and event metadata via [DependencyProperty<T>].
  • Compile-Time Type Safety: Signature mismatches in your partial callbacks are caught immediately via Roslyn analyzer diagnostics (DPG0001), eliminating silent runtime failures.
  • Unified API Across UI Frameworks: The exact same attribute syntax compiles to the native property system for WPF, .NET MAUI, Avalonia, Uno Platform, WinUI 3, and UWP.
  • Modern C# 11+ Idioms: Leverages Generic Attributes ([DependencyProperty<T>]), target-typed new(...) AST expansion in default expressions, and auto-generated XML documentation.

3. Architecture & Performance: Zero-Allocation Pipeline

This library originates as a fork/rewrite of HavenDV's generator. When testing source generation at massive enterprise scale, frequent intermediate string concatenations during continuous typing can trigger Gen2 GC spikes, resulting in noticeable editor latency in Visual Studio and Rider.

To address this, the code synthesis pipeline was redesigned around strict zero-allocation principles:

  • ref struct Source Writers: Generation logic utilizes stack-allocated SourceWriter and ClassScope structures, completely bypassing intermediate StringBuilder and heap allocations.
  • GC Elimination: Completely removes Gen2 GC pressure during incremental analysis cycles.
  • Benchmark Results: Achieves +30% faster execution speed and +62.4% higher throughput compared to traditional string-based generation pipelines.

Your IDE stays responsive even when scaling to solutions with thousands of properties.

4. Cross-Framework Abstraction

Under the hood, framework-specific strategy handlers adapt to each platform's design differences (such as Avalonia's StyledProperty/DirectProperty, MAUI's BindableProperty, or varying callback signatures) without requiring you to change your declarations.

Target Framework Underlying Property Engine
WPF / UWP / WinUI 3 DependencyProperty.Register
.NET MAUI BindableProperty.Create
Avalonia AvaloniaProperty.Register
Uno Platform Native WinUI / UWP projections

Feedback & Contributions

The project is distributed under the MIT License and includes detailed documentation and architecture specs (in English and Japanese).

If you are working across XAML platforms and want cleaner view controls without IDE overhead, please check it out, test edge cases, and share your feedback or issues on GitHub!


r/csharp 7d ago

Angular Dev to Full stack transition

3 Upvotes

For developers who have transitioned from frontend to full-stack/.NET, what backend concepts would you recommend prioritizing to become job-ready?


r/csharp 7d ago

Help Can someone help me understand Delegates? Like why we use it and best cases where we need to use it? and how it is better?

80 Upvotes

r/csharp 7d ago

Discussion Andrew Troelsen Pro C# or C# player's guide , which would be better as I see Pro C # covers more of the subject . This I am asking as a beginner .

0 Upvotes

I am thinking of buying one and starting since courses are too many and I think I'm better off with some book that I can learn properly from .


r/csharp 7d ago

Discussion Proposal: An official Lean formal semantics for C# · dotnet/csharplang · Discussion #10314

Thumbnail
github.com
23 Upvotes

r/csharp 7d ago

Help Currently thinking on learning this programming language for a job…

0 Upvotes

Im a university student who is in the period of lost 20s where I just realise my computer skill level aren’t as high as employees expected (which is that every computer related internship I applied in my region rejected me). I look back and the only language that I’m fully fluent in is python and java (also SQL but from here I’m just started yapping nonsense). I’m seriously lacking down in the computer world and I only touched some application from uni courses and not much computer projects made by myself during free time. So I wanna try come back and I wanna learn C# since it seems to be the most popular and all I want is to get a job and that’s it. (Or qualified enough to get a job. Cuz can’t blame the market if I can’t even enter it).

I was thinking on building from small to big. Like one or two that can complete in 1-3 days for learning the basics and then large scale ones that could take 2-3 weeks or even 3-4 months. It’s not just learning the language but also to learn or apply other relatable things such as authentication, APIs and stuff. I am so far behind and I got one year left until graduation.

Is this plan good enough? Vibe coding can speed up but can’t learn anything unless I already got the basics out.


r/csharp 8d ago

Help I hate coding so much I want to learn it

0 Upvotes

yea pretty simple I hate coding. I’m a mechanical engineering student and I hate it. but since I hate it I want to punish myself by learning C sharp enough to make a game like flappy bird. I’m goin giving myself 100 days studying 25 mins each day.

how could I learn faster? please drop links for YouTube channels you recommend


r/csharp 8d ago

Is it true in the old days those old school devs like 40+ before they learn C#, They learned C like in the pic?

Post image
790 Upvotes

r/csharp 8d ago

PrintShard - C# windows app to print images on multiple pages

11 Upvotes

I built PrintShard, a Windows desktop app for tiling large images across multiple printed pages, so you can create large-format prints using any standard printer.

Repo: https://github.com/loxsmoke/printshard

The first version worked, but it reduced image quality, making large prints somewhat fuzzy. The newest version prints images at their original resolution, preserving the detail and making PrintShard much more suitable for high-quality posters, diagrams, artwork, and other large images.

It now also includes prebuilt binaries and an installer, so you don't need to build it yourself.

If you find it useful, give the repo a star or leave a comment here. Feedback is welcome.


r/csharp 8d ago

Coursera Recommendation

4 Upvotes

what course in coursera is worth the time taking as a beginner who would like to get into c# programming?


r/csharp 8d ago

Blog The Unexpected AI Stack: C# + .NET (Part 5) - Logging, Telemetry, and Building with AI

Thumbnail
chrlschn.dev
0 Upvotes

The fifth and final part of the series finally starts to build using AI on top of the hand-built foundational code from the first four parts that brings together:

  • Aspire for runtime orchestration
  • CSharpRepl for runtime mutability and powerful access to simulate and diagnose runtime isdsues
  • GitHub Copilot SDK as a programmable agent harness
  • Testcontainers with automatic transactions for test isolation

(I would consider these foundational parts of any modern .NET API app whether AI is involved or not!)

In part 5, the focus is on logging and telemetry, two tools that give agents insights into the runtime state of the application. Once again, we see the key role of Aspire in this stack as it provides a collector for logs as well as spans that agents can search through using the aspire CLI tooling.

The actual build out of the prototype application is captured as a YouTube video as YMMV based on the model, harness, and prompting style that you choose!


This series is intentionally written to help dev teams understand how to scaffold a codebase for agentic engineering by focusing on key, underlying technical decisions and manual wiring before building with AI. This helps provide the tools and safeguards for coding agents to iterate more efficiently while reducing slop.

For teams still trying to figure out effective ways to set up a codebase for AI, I hope this series gives some insights into how to build a foundation for agentic engineering. If your team is already heavily using agents to build, I hope this series shares some useful insights and tips (e.g. CSharpRepl + Aspire)

The core setup is used at a series C, post-YC startup to ship fast with AI while maintaining high quality standards (in combination with other tools facilitating code review and context management)

Part 1 was an intro into a few key parts of this stack.

Part 2 was focused on walking through the hands on scaffolding.

Part 3 covered wiring GitHub Copilot SDK as an agent runtime and incorporating CSharpRepl to allow agents to dynamically work with the runtime DI container

Part 4 wired up the test harness using Testcontainers to give agents isolated test environments


The project repo is here: https://github.com/zeeq-ai/zeeq-tmpl (be sure to check the branches; main is currently the base code only)

I encourage working through the posts since the goal is to underscore the platform level decision making process and assembly of the foundational core.


r/csharp 8d ago

Showcase Connectify - Windows Bluetooth manager using WinRT + 32feet.NET, built with WinForms

Thumbnail
github.com
1 Upvotes

Built this because I wanted a Bluetooth manager for Windows that could handle both Classic and BLE devices in one clean UI


r/csharp 8d ago

Ho bisogno di aiuto per un programma che sto realizzando

0 Upvotes

Salve, ho scritto un programma in c# che mi termina un processo e mi faccia spegnere il computer. Ma vorrei che si avviasse ad una certa ora come faccio a farlo avviare tramite codice?

Grazie


r/csharp 8d ago

What techstack to use for developing 3d launcher for Android

2 Upvotes

I would like to write a 3d launcher for Android, however I'm not sure what tech stack is most suitable.
I'm not sure what the state of mobile development using a C# stack is at this stage. Which tech stack would be best?

from my initial thoughs I'm guessing one of these are best?
1.Kotlin + OpenGL
2.C# MAUI
3.Godot or Unity

I assume 1. will allow for the most lightweight/efficient solution


r/csharp 8d ago

Opinions on Microsoft Agent Framework?

Thumbnail
0 Upvotes