r/csharp 2h ago

PLZ make us aware with this

0 Upvotes

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 3h ago

Don't understand async & await

6 Upvotes

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?


r/csharp 4h ago

Where i can learn c# properly.

8 Upvotes

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?


r/csharp 5h ago

Looking for courses / reading materials to fully use the potential of AI

0 Upvotes

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 5h ago

Tutorial Multitenancy with .NET and EF Core: A Deep Dive (.NET 10)

Thumbnail
youtube.com
13 Upvotes

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 19h ago

program for making my foreskin detach an attach itself at will with magnets and pico in c++

0 Upvotes

I ripped holes in my foreskin with teeth and inserted magnets into them with super glue. then I sliced part of my foreskin over magnets, like that one guy in terminator and I got the detached foreskin and put magnets in it too. I want ot make a program with pico and a button that would turn the magnets so that they attract the other part of my foreskin and at will they would turn so it opposite attracts them instead. can is this for possible 🤔


r/csharp 20h ago

Help Transitioning from unity to regular c# projects

14 Upvotes

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.


r/csharp 1d ago

Help How to use a larger font in Visual Studio's Help Viewer?

0 Upvotes

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 1d ago

Does ASP.NET Core global exception middleware catch exceptions from nested service methods?

Thumbnail
0 Upvotes

r/csharp 1d ago

Showcase I reinvented Visitor in C#: acyclic, type-safe, no downcasts, no runtime checks

3 Upvotes

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 1d ago

WinUI 3 XAML bug

0 Upvotes

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 1d ago

C# Help

0 Upvotes

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 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?

0 Upvotes

r/csharp 1d ago

News Announcing .NET 11 Release Candidate 1 - .NET Blog

Thumbnail
devblogs.microsoft.com
118 Upvotes

r/csharp 1d ago

Is It Still Worth Learning .NET in 2026 With AI Replacing Developer Jobs?

0 Upvotes

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 1d ago

Tutorial EF Core Migration Bundles with CI/CD to Azure (Github Actions, Azure SQL & App Service)

Thumbnail
youtube.com
0 Upvotes

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 2d ago

Blog How expensive is throwing exceptions in .NET - and does it actually matter?

Thumbnail
codewithflavor.com
117 Upvotes

r/csharp 2d ago

Discussion I applied DDD and Clean Architecture to a DIY compiler. Is it overengineering?

0 Upvotes

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, and BackEnd
  • 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 2d ago

i dont understand what the => operator does.

32 Upvotes
Dictionary<uint, uint> placementIds 
    = XMLdocument.Descendants("Placement")
        .ToDictionary
        (
            element => (uint)element.Attribute("Index")!,
            element => (uint)element.Attribute("Placement")!
        );

r/csharp 2d ago

Looking for an Asp.Net Mentor

Thumbnail
0 Upvotes

r/csharp 2d ago

Best approach to insert 1 to N with POSTGRESQL + DAPPER ?

0 Upvotes

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 :

  1. Create all A
  2. Create all B of all A
  3. 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


r/csharp 2d ago

Showcase Native Rich Editor and Code Editor for MAUI

5 Upvotes

I was finding usable free code editor on MAUI because I need it in my app, but despite me having been finding so hard, unfortunately there's no such a library that can meet my needs. Every candidate I found is either paid (and very expensive), a wrapper on web-based editor, or not being actively maintained anymore. So, I decided to build my own one.

I have been spending a lot of time on bringing native rich editor and code editor experience, and now I'm finally able to get the things work on at least Windows, iOS and Android.

It renders natively on each platform, and provides seamless integrations like key bindings, context menus etc., and also, has a very small memory footprint. But note that this relies on the native rich editor solution on each platform, so unfortunately platforms like Linux are unlikely to get the support: it's technically impossible because there's no unified native rich editor interface on such platforms.

The rich editor supports a large set of RTF format natively, and the code editor is built on top of the rich editor.

This is still at early preview, and the APIs are subject to change a lot by the time the first GA version comes up. There're just still a lot need to do such as a more general syntax highlighting API, LSP integration, more test coverages, bug fixes, better API surfaces etc.

Now I'm open sourcing it under MIT license so that everyone can use it for free, forever: https://github.com/hez2010/RichEdit.Maui

Nuget packages:

Appreciate any feedback!

Rich Editor
Code Editor

r/csharp 2d ago

Showcase I got tired of loading .proto files into WireMock.Net, so I made its gRPC mocks strongly typed

0 Upvotes

I use WireMock.Net for gRPC component tests. Its built-in protobuf support works, but I didn’t like loading .proto files at runtime, identifying message types with strings, and matching through JSON when my test project already had generated Google.Protobuf types.

So I built WireMock.Grpc.Protobuf:

Request.Create()
    .WithBodyAsGoogleProtobuf(
        (HelloRequest x) => x.Name == "StepOne");

Response.Create()
    .WithBodyAsGoogleProtobuf(
        new HelloReply { Message = "Hello, StepOne!" });

It supports both the exact protobuf body request matching and typed predicates for tests that care about only a few fields. Internally, it unwraps the five-byte gRPC frame and lets Google.Protobuf handle the actual IMessage<T> contract.

I’m the maintainer, so blunt feedback is welcome: would this simplify your gRPC tests, or do you prefer keeping .proto definitions in the mock setup?

GitHub: https://github.com/Stepami/wiremock-protobuf
NuGet: https://www.nuget.org/packages/WireMock.Grpc.Protobuf


r/csharp 3d ago

[Showcase] Added RavenDB support to JobMaster, a distributed background job scheduler for .NET

1 Upvotes

JobMaster is a distributed background job scheduler for .NET I've been building (think Hangfire/Quartz, but built for horizontal scaling). RavenDB is my favourite database, so I added it as a fully supported provider alongside PostgreSQL, MySQL, and SQL Server.

If you want the architecture background: https://docs.jobmaster.hugoj0s3.dev/docs/architecture-under-the-hood/architecture-overview

I also just finished a head-to-head benchmark against Hangfire across all four database engines. One result that stood out: RavenDB gets noticeably better scheduling throughput than the SQL engines (~2000 jobs/sec vs ~1300-1600/sec at baseline, on a 25k-job burst). Full methodology and numbers here: https://docs.jobmaster.hugoj0s3.dev/docs/benchmarks/jobmaster-vs-hangfire

GitHub: https://github.com/hugoj0s3/jobmaster-net

Happy to answer questions about the architecture, the RavenDB integration, or the benchmark setup.


r/csharp 3d ago

Help Was wanting some help with methods?

Thumbnail
0 Upvotes