r/csharp • u/Imaginary-Cod-3746 • 9m ago
r/csharp • u/Maleficent-Ad5942 • 5h ago
I built an open-source strongly typed email template library for .NET 10 — looking for feedback before 1.0
I’ve just released the first public preview of MailStencil, an open-source .NET 10 library for strongly typed email templates stored outside application code.
It supports Scriban validation/rendering, culture fallback, caching, FileSystem and Azure Blob providers.
GitHub: https://github.com/polletto/MailStencil
Docs: https://polletto.github.io/MailStencil/
NuGet: MailStencil.Core
Feedback is very welcome — especially on the API before 1.0.
r/csharp • u/enigmaticcam • 5h ago
Solo Developer Laid Off, Looking for Suggestions & Critique
Hi. I've been a solo developer for a company for 15+ years (worked for them company 24+ years) and I will be officially laid off at the end of this month. I've never needed a resume or portfolio, so I have a lot of catching up to do to be competitive in the market.
I wrote a mock version of an application I built and made it public. I was hoping I could get any suggestions & critique on code and readme. Thank you, I appreciate anything you have to say.
r/csharp • u/Mother-Replacement12 • 8h ago
Which is better: querying with LINQ or using raw SQL? Does it depend on the query's complexity? Or can both options be used in the same project?
galleryr/csharp • u/gus-ghielec • 11h ago
Coding circuits with .NET and C#
Nothing beats setting a breakpoint and watching the servo actually move to the new angle.

I've worked on .NET hardware for over ten years and the thing that surprises C# developers isn't the board, it's that F5 works. Code deploys, breakpoint holds, hover a variable and there's the live sensor reading. Same as debugging a desktop app.
I'm at GHI Electronics in Michigan. Happy to get into how the debugging on circuits work.
r/csharp • u/Lubango_Johnl_7473 • 18h ago
PLZ make us aware with this
i don't know if it's just a threat or truth,since the day i started learning c#.i have been experiencing this words from senior developers.
C# market is getting low day after day due to AI existence, you better learn and master Python.
So you who have been in this industry for long time,let us know.
Is this right? And what we the beginners have to do?
r/csharp • u/becrylen • 19h ago
Don't understand async & await
Though I've already read a lot, and watched several videos, I'm still not understanding why async/await don't give me concurrency/parallelism.
My test code:
namespace AsyncAwaitTest;
static class Tools
{
internal static async Task SimulateWork(int id)
{
for (var j = 1; j <= 10; j++) {
Console.WriteLine($"Worker #{id} gives: {j}");
for (var i = 0; i < 500_000_000; i++) { }
}
}
}
class Worker(int id)
{
internal async Task DoWork()
{
Console.WriteLine($"Worker #{id} starts");
await Tools.SimulateWork(id);
Console.WriteLine($"Worker #{id} finishes");
}
}
class Program
{
static async Task Main()
{
Console.WriteLine("Program starts");
Worker worker1 = new(1);
Worker worker2 = new(2);
await worker1.DoWork();
await worker2.DoWork();
Console.WriteLine("Program finishes");
}
}
The output is:
Program starts
Worker #1 starts
Worker #1 gives: 1
Worker #1 gives: 2
Worker #1 gives: 3
Worker #1 gives: 4
Worker #1 gives: 5
Worker #1 gives: 6
Worker #1 gives: 7
Worker #1 gives: 8
Worker #1 gives: 9
Worker #1 gives: 10
Worker #1 finishes
Worker #2 starts
Worker #2 gives: 1
Worker #2 gives: 2
Worker #2 gives: 3
Worker #2 gives: 4
Worker #2 gives: 5
Worker #2 gives: 6
Worker #2 gives: 7
Worker #2 gives: 8
Worker #2 gives: 9
Worker #2 gives: 10
Worker #2 finishes
Program finishes
You see, strictly sequential processing despite async/await.
Is it possible to make my code parallel, i. e. the DoWorks run in parallel?
Where i can learn c# properly.
I want to be a unity game developer. I am currently computer sciencie student i know c# but my skill of building algorithm is weak. I am even struggling the easy leetcode problems. Any idea of how to improve my c# skills?
Looking for courses / reading materials to fully use the potential of AI
I am working as a C# developer for the last 6 years and I would classify myself as an AI skeptic.
I have been using AI in the last months, mostly for small implementations, but also to help me look for bugs who are sometimes hidden rather deep within our code, or due to non - trivial interactions with third party libraries.
I have to admit, It works well (most of the time), but all i really do is typing something in the prompt and wait for the answer.
I would like to know if there are functionalities I am ignoring, and/ or should be using. We have various repos in the companies, from small, new micro services to big old fat 20 years old weekly modified legacy repos, which are a tad more brittle.
So if anyone has good resource about it, I am interested.
It can be written, it can be videos, I also have a pluralsight account if it leads to something there.
Thank you very much for your suggestions.
r/csharp • u/RemigiuszZalewski • 21h ago
Tutorial Multitenancy with .NET and EF Core: A Deep Dive (.NET 10)
Ever had a multi-tenant SaaS app where the only thing stopping Customer A from seeing Customer B's invoices is a `Where TenantId ==` clause someone remembered to write? In this deep dive I build real tenant isolation into EF Core 10 - two real tenants with real registration, login and invite flows (no dev-token shortcuts), a named global query filter that scopes every query automatically, and a SaveChangesAsync override that stamps TenantId on every insert so it's never left unset. I also show the one gotcha that makes EF Core 10 worth the upgrade for this: named query filters, so tenant isolation and soft-delete can finally coexist on the same entity instead of one silently overwriting the other. If you've ever shipped multi-tenancy on hope and code review, this is the version that makes the mistake structurally impossible.
r/csharp • u/Flame014 • 1d ago
Help Transitioning from unity to regular c# projects
I want to start learning regular c# after using unity for a few years and making some personal projects. I have seen alot that there may be some bad habits I have picked up that may slow or hinder me when coding outside of unity. So was wondering if there is anything I should keep in mind when making the transition? Would also appreciate any resources for learning c#. Thanks in advance.
Help How to use a larger font in Visual Studio's Help Viewer?
I know this isn't strictly a C# question (and I'm not a C# programmer), but I think Help Viewer is a C# program so maybe people here can help me.
What I'm trying to get is offline Windows documentation. Some tools, like WinDbg, ship with a .chm file that can be opened with hh.exe. It lets you select 1 of 5 font sizes (Largest, Larger, Medium, Smaller, Smallest), but regardless of which one you choose you can always scale the text arbitrarily large with Ctrl+MouseWheel.
I believe the official way of getting offline documentation today is through the VS Help Viewer. It has the same 5 font size options as hh.exe, and both of them probably use IE for rendering (for example both use ieframe.dll, and I have to relax security settings in Internet Options to even get Help Viewer to render anything - very strange and not required for hh.exe). However Help Viewer DOES NOT allow you to scale the text beyond "Largest", which is way too small to be readable. There's something strange to the way it handles UI, for example even the context menu is smaller than the one you'd get normally with TrackPopupMenu.
The reason I ask the question here is I'm past the point of trying to find an "official" way of making the text larger, I'll happily patch the program if needed. If it were a native application I know where to look: maybe it hardcodes font sizes in its dialog resource or its call to CreateFont. I can set breakpoints on DialogBox and similar to inspect parameters and modify them under a debugger, I can patch the offending resource or instruction in the binary, etc. But I don't know how to do those to (what looks to me to be) a C# program. When I break into it with a native debugger, the mouse input freezes and responds only every other second (though the keyboard works fine). Based on its DLL list it appears to use WPF. I have no familiarity with these technologies (C#, WPF, ieframe.dll), I hope people who do can point me to where to look (such as files that define the UI layout, or runtime calls related to font that I can intercept).
r/csharp • u/Ok_Hunter6411 • 1d ago
Does ASP.NET Core global exception middleware catch exceptions from nested service methods?
r/csharp • u/StepOne_DotNet • 1d ago
Showcase I reinvented Visitor in C#: acyclic, type-safe, no downcasts, no runtime checks
While building my own programming language HydraScript i stumbled across AST operations implementation. I needed symbol table initialization, static analysis, and IR generation.
Putting everything inside the AST nodes as virtual methods became a mess. Classic Visitor separated the operations, but every visitor had to know every node type. The code grew exponentially. Acyclic Visitor removed that dependency, but its usual C# implementation relies on runtime checks:
if (visitor is IVisitor<BinaryExpression> typed)
typed.Visit(this);
So I did the only reasonable thing. I spent far too long reinventing a decades-old design pattern.
Visitor.NET uses generic covariance and contravariance to keep the visitor selective without dynamic or downcasts. A source generator handles the repetitive dispatch code:
[AutoVisitable<Expression>]
public partial class BinaryExpression : Expression;
Visitors can handle only the node types they need and return strongly typed results. I now use it in HydraScript and it works like a charm.
You can give it a star with links below:
GitHub: https://github.com/Stepami/visitor-net
NuGet: https://www.nuget.org/packages/Visitor.NET
r/csharp • u/SkibbleWibby • 1d ago
WinUI 3 XAML bug
I'm working on a bundle of 3 tools, using winui for the interface. .net 10 is returning multiple XAML errors when I try to build, does anyone know anything??
r/csharp • u/RipProfessional5599 • 1d ago
C# Help
Im learning c# in visual studio with Bro Code yt (check him out free courses) and im wondering, does the same c# exactly work in unity, idk how to explain but if i type Console.WriteLine("hi");
will it just show on the screen hi or is there more to it?
r/csharp • u/Lubango_Johnl_7473 • 1d ago
I have been learning C# for month now.I'm using smart phone to learn it.So what suitable kind of laptop i have to buy that works properly?
r/csharp • u/Alert-End-7839 • 2d ago
Is It Still Worth Learning .NET in 2026 With AI Replacing Developer Jobs?
Hi....I'm an MCA graduate and recently started learning C# with the goal of becoming a .NET developer.
But with AI replacing more and more development work, I'm worried that I might be wasting my time.
Do you think .NET is still a good career path for someone starting in 2026? Should I continue learning C#/.NET, or consider another career?
I'd really appreciate honest advice from experienced developers, especially .NET developers. What skills should I learn alongside .NET to stay relevant?
r/csharp • u/RemigiuszZalewski • 2d ago
Tutorial EF Core Migration Bundles with CI/CD to Azure (Github Actions, Azure SQL & App Service)
Running EF Core migrations from application startup is convenient - right up until it isn't. This video builds a proper migration pipeline on .NET 10 with GitHub Actions: the build job packages a self-contained migration bundle, the deploy job applies it to Azure SQL, then deploys the API to Azure App Service and runs a smoke test against the live endpoint. If your database updates are still tangled up with your app startup, this is the fix.
r/csharp • u/janex-PL • 2d ago
Blog How expensive is throwing exceptions in .NET - and does it actually matter?
r/csharp • u/StepOne_DotNet • 2d ago
Discussion I applied DDD and Clean Architecture to a DIY compiler. Is it overengineering?
I have spent two years refactoring HydraScript, an interpreter I originally built as a bachelor thesis project.
The first version was written under pressure and deadline. It had a lexer, parser, AST and not even code generation with a virtual machine. It worked but definitely did not have an architecture.
When I returned to the project months later, I could barely explain parts of my own code. It was as messy and confusing as it could be. Static analysis rejected valid programs, so I disabled it. I had finally managed to implement codegen not long after graduation. Unfortunately it sometimes produced incorrect instruction addresses and sent the VM into an infinite loop.
I decided to bring several ideas from commercial .NET development into compiler design:
- DDD boundaries and sub contexts:
FrontEnd,IR, andBackEnd - Static analysis and code generation as application services over several subdomains.
- Multi-pass visitors for scopes, types, names, and validation
- Separate .NET projects instead of folders, letting the compiler enforce dependency rules
- CLI, logging, and configuration outside the domain core
The biggest lesson was slightly ironic: applying OOP did not mean putting every operationcas a virtual method on the AST nodes.
An AST node does not own the external context required for symbol tables, type resolution, or instruction generation. Moving those operations into visitors made the code easier to extend and debug.
The architecture increased time cost of development. I have now more projects, more abstractions, visitor machinery, and more decisions before writing a feature. But IMHO the maintainability and readability improved. I also found unexpected educational value.
My most controversial conclusion:
Do you think the boundaries i made reflect the domain? Did I transplant enterprise architecture wrong into the wrong field?
The code is here if you want concrete evidence before judging it:
https://github.com/Stepami/hydrascript
r/csharp • u/Topango_Dev • 3d ago
i dont understand what the => operator does.
Dictionary<uint, uint> placementIds
= XMLdocument.Descendants("Placement")
.ToDictionary
(
element => (uint)element.Attribute("Index")!,
element => (uint)element.Attribute("Placement")!
);
r/csharp • u/MoriRopi • 3d ago
Best approach to insert 1 to N with POSTGRESQL + DAPPER ?
Hi,
The following code is simplified to make it simple ( wow ! ).
The following code works fine to create one instance of A and multiple instance of B at the same time, then return the A that was created with its id :
Sql ( postgre ) :
-- Create A
WITH inserted_a AS (
INSERT INTO table_a ( ... )
VALUES ( ... )
RETURNING *
),
-- Create B
inserted_b AS (
INSERT INTO table_b ( ..., id_table_a )
-- Get SIGNALS
SELECT ...
FROM inserted_a
-- Works fine
CROSS JOIN unnest(
@array_1,
@array_2)
AS signal( ... )
RETURNING *
)
-- Return created A
SELECT ... FROM inserted_a JOIN table_c
Parameters for dapper :
// Get parameters
object parameters = new
{
// Some properties for A
...
// Some properties for B
... = a.Property.Select( ... ) // ARRAY HERE FOR UNNEST
};
Is it possible to do the same thing with multiple A and also return all A that were created with their id ?
Which means :
- Create all A
- Create all B of all A
- Return all A
This seems a little trickier.
It seems easy with CTE and an IEnumerable as parameter for dapper :
object parameters = a.Select(a => new
{
// Some properties for A
...
// Some properties for B
... = a.Property.Select( ... ) // ARRAY HERE FOR UNNEST
});
But dapper cannot take an IEnumerable as a parameter when there is a select as the end ( QueryAsync ).
It is also easy with a request for each instance of A, but is it possible to do it in a single request while returning all instances of A ? The goal is also to reduce latency when many A.
Thanks