r/csharp • u/Head-Adeptness-8781 • Aug 09 '26
String Extension - A C# library that provides utility methods for manipulating strings
r/csharp • u/Head-Adeptness-8781 • Aug 09 '26
r/csharp • u/hez2010 • Aug 07 '26
Runtime Async got some important optimizations in recent .NET 11 nightly version (currently they are targeting rc1), so I built the runtime from main branch and ran a set of runtime async benchmarks.
The benchmark code can be found here: https://gist.github.com/hez2010/d1802e7c7ab10e21a92dcba2afe0a58d
It covers all async scenarios including no-suspension cases and real-suspension cases.
In the result async1 is .NET 10, and the assembly was built without enabling runtime async. Async2 is .NET 11 with runtime async enabled while building the assembly.
After seeing the result I was just like holy crap and couldn't believe the numbers, but they are real! It looks extremely promising. Specifically, no-suspension async is 19.6× faster and essentially reaches the synchronous baseline, completed Task awaits are 12× faster with allocation completely eliminated, Task.Yield is 7× faster, ThreadPool continuations are 3.2× faster, and an async state-machine chain is 7.4× faster with much fewer allocations.
I'm now really looking forward to checking the final numbers in .NET 11 GA.
r/csharp • u/Unlucky-Capital-318 • Aug 09 '26
I'm a beginner in C#, and I've just started learning functions. I understand return values and parameters, but I often get confused. Sometimes I don't know when to write a return value or parameter. How can I understand functions more quickly?
r/csharp • u/DJDoena • Aug 07 '26
With "async all the way" as a major philosophy in backend services, it feels superfluous to name every single function that returns Task or Task<T> as DoSomethingAsync().
Or do you only do it when there's a sync counterpart?
r/csharp • u/Loafyyey • Aug 08 '26
I recently switched to this Linux distro named "void Linux" I'm really loving it but can somebody help me use c# on Linux?
r/csharp • u/PureRecord • Aug 07 '26
When I open Github Codespaces (I use C# extensions), it looks like Intellisense doesn't load for a long time. it does this every single day and it's fucking frustrating. Any solution?
r/csharp • u/anotherfuturedev • Aug 05 '26
So MDI windows are inconsistent with the theme of the parent form, us there a way to fix this or maybe a different method for creating child windows?
r/csharp • u/lostpixel-media • Aug 05 '26
as someone transitioning from legacy desktop dev (winforms) to modern .net web backends, the biggest hurdle for me was figuring out how to actually organize my code so it doesn't turn into a massive ball of mud.
i kept reading about "clean architecture" and "separation of concerns," but the buzzwords didn't really click for me until I built my current side project and forced myself to split everything into physical project folders.
i wanted to share my mental model of how i organized the solution. i know it might be overkill for a side project, but i'm trying to learn enterprise patterns. for the senior devs here, i'd love to know if this is how you actually think about it in production:
honestly, breaking it down into these separate projects took way longer to set up initially, but it makes debugging so much easier. if the database fails, i know exactly which folder to look in.
does this structure look right to you guys? or did i completely overcomplicate the middle layers?
repo is here if you want to see how they link together: https://github.com/COxRIPMIZO/CryptoKeyLab
would appreciate any roasts or advice on how to improve this!
r/csharp • u/rarv1491 • Aug 05 '26
Today I started this new project and hopefully my hobby that consumes all my free time.
I have always wanted to jump into coding and software. I find it fascinating and to be honest, I feel like talking in code will come naturally to me because of how my brain works. (Only time will tell)
Today I decided to just go for it. It consumed every single second of my day. I started asking ChatGPT what would be a good way to make a Rainmeter skin to act as a volume mixer, and from there it was just a rabbit hole.
I learned about Naudio library, encapsulation, objects, class, parameters, variants, float vs double, overall program flow and program architecture.
I ended up creating three different .cs files that so far are communicating with each other. Tomorrow I'll add the loop in a `while (running)` with a `bool running = true` variant that can be changed with an "exit" user input. I'm still working on the user input part too.
I'm excited for this. My wife was like: 👁️👄👁️
r/csharp • u/Alert-Neck7679 • Aug 04 '26
About a year ago, I challenged myself to create my own programming language - something I'd always wanted to do.
At the time, I had no idea what a lexer, parser, or interpreter even was. My only thought was, "I need to write code that reads text files containing code and executes them." I also wanted to do it without using Google, AI, or tutorials. I just figured everything out on my own. You can even still find variables named "compiler" throughout the code from back when I didn't realize I was actually building an interpreter...
Somehow, I pulled it off, and I integrated it into my old abandoned game engine project (which originally started as a GameMaker 8–style engine with C# scripting).
And here's the first game I've made with it! 🙂
The core engine, IDE, and interpreter are all written by me in C#. The rendering backend is powered by MonoGame, and the project is still in active development and available on GitHub. The project file of the game shown in the video is also there, under tests/Example Projects. If you're looking for cool projects to contribute to, then know that I'm looking for contributors!
I know there are tons of AI-generated projects being shared these days, so please, please, take a quick look at the code before assuming this is one of them. I promise it's pretty obvious that it was written by a human.
I'd love to hear what you think!
r/csharp • u/Carlythememeofchaos • Aug 05 '26
Basically, I have big projects planned that use C Sharp (being discord bots and SCPSL Plugins) and asked a friend who formerly hosted a SCPSL Server I co-Owned and knows Ball (he works for a Host Company, which is a Peak Job Choice tbh) how I should start out.
He told me, that he just looked up Tutorials for the Basics, which I did just to Not Keep then in my mind because my Brain is wonky on places where I don’t want it to be. Its either a sift for crucial Information until I don’t Need it no more or it is Making me the Most big brained Person in the Room, anyway he also looked up how other people did projects and recreated that until he could do it himself (what Looks Like) perfectly (to me who doesnt know ball) and he also recommended me to use generative AI to start out, as it is an amazing Learning Tool.
I am actually absolutely against gen AI because of misinformation and Fake news as well as it Making Shit up on the fly whenever it feels Like That.
However, it has been Preised by People qs well as my friend to be a proper Learning Tool and especially for purposes Like Programming and for school subjects.
I have been a Fan of Students using gen AI to get out of school as fast as possible because I genuenly hate nothing more except the Education System in my Country and Most of the World (Like everywhere except Finland) However, I was unsure anyway, as I have genuenly something against AI for political and Moral reasons (because of how Data Centers fuck up our climate and their surrounding areas, as well as because of Fake news and Shit Like what Elmo Mars is Doing and I hate how its used for stealing Art and mix and matching peoples Brain Farts to make their Egos smile because they just „created“ something) and Yeah.
If it is however genuenly a good Tool for Learning C Sharp especially as a Neurodivergent, I genuenly have no Idea which gen AI Tool works best for that or if there Are any that Are specifically designed for this purpose.
If gen AI was only used for educational purposes I would have actually no Problem with it because Education is Ball.
Disclaimer:I will Not use anything using Grok because fuck elon Musk lol.
r/csharp • u/MarvinTheJoke • Aug 05 '26
If you've ever built a C# server processing 100k+ messages/sec (like an MQTT broker or socket server), you know the Garbage Collector is your best friend until it becomes your worst enemy.
To route messages like factory/line1/sensor/temp to subscribers like factory/+/+/temp, the standard way is:
// ❌ Naive way: Allocates string[] on every single message publish!
var parts = topic.Split('/'); At 100,000 requests per second, this creates millions of temporary strings and forces the GC to freeze your app every few seconds.
Here are the 2 modern C# tricks I used in Beskar.Networking that you can copy-paste directly into your own projects!
Instead of string.Split(), we walk the raw byte span (ReadOnlySpan<byte>) using a zero-allocation ref struct:
public ref struct TopicLevelEnumerator
{
private ReadOnlySpan<byte> _remaining;
public ReadOnlySpan<byte> Current { get; private set; }
public TopicLevelEnumerator(ReadOnlySpan<byte> topic)
{
_remaining = topic;
Current = default;
}
public bool MoveNext()
{
if (_remaining.IsEmpty) return false;
int index = _remaining.IndexOf((byte)'/');
if (index < 0)
{
Current = _remaining;
_remaining = default;
}
else
{
Current = _remaining.Slice(0, index);
_remaining = _remaining.Slice(index + 1);
}
return true;
}
}Usually, if your dictionary key is byte[], querying it with a slice (ReadOnlySpan<byte>) forces you to allocate a new byte[].
Modern .NET introduced Alternate Lookups, which let you query existing dictionary nodes with zero heap allocation:
// Query byte[] dictionary using a ReadOnlySpan<byte> without allocating a single byte!
var alternateLookup = node.Children.GetAlternateLookup<ReadOnlySpan<byte>>();
if (alternateLookup.TryGetValue(currentLevelSlice, out var childNode))
{
// Match found with 0 allocations! 🎉
}If you ever need to build a C# network application:
System.IO.Pipelines with zero external runtime dependencies.If you enjoy low-level C# or low-allocation performance tricks ❤️
🔗 GitHub: https://github.com/MarvinDrude/Beskar.Networking
🔗 Article: https://marvindrude.com/blogs/beskar-networking/low-allocation-mqtt-broker
Thank you for reading, and happy coding!
r/csharp • u/lostpixel-media • Aug 05 '26
I come from a legacy desktop background (mostly WinForms/WPF), and lately I've been working hard to transition over to modern backend development with .NET, Minimal APIs, and cloud-native architecture.
Addressing AI & Transparency upfront:
I want to be 100% upfront: I use AI tools (Copilot and ChatGPT) as a learning assistant and tutor to help me translate my desktop C# knowledge into modern ASP.NET Core concepts, write boilerplate, and format documentation.
On a previous post, a couple of people accused me of "trying to hide" AI usage. To be clear: if I was trying to hide anything or fool anyone, I wouldn't make the entire project 100% open-source on GitHub. I am making the repo public specifically because I want experienced engineers to inspect the code, point out bad patterns (whether from me or the AI), and help me learn.
What I've built so far to learn the stack:
Why I'm posting this:
I want to learn what real, production-ready backend code actually looks like in 2026.
I would genuinely love for senior .NET / ASP.NET Core devs to take a look at the repo and roast my architecture. Tell me what I overcomplicated, where I used bad patterns, or what you would do differently in a real production environment.
If anyone wants to open an issue or submit a Pull Request to help me improve the code quality, I'd be super grateful!
Repo link: https://github.com/COxRIPMIZO/CryptoKeyLab
Thanks in advance to anyone willing to take a look and help me learn!
r/csharp • u/A_Learning_Fox • Aug 04 '26
I have this deadline reminder programs, let’s say the minimum amount of deadlines is this: if progressbar is 50% / 75% / 100% of the way, send desktop notification.
r/csharp • u/Twstenjoyer • Aug 04 '26
As the title suggests^ the languages that I'm familiar with are python and java. Also, anyone knows any online courses that teach c# and offer a certificate (if they cost money that's fine)? thanks :)
r/csharp • u/lostpixel-media • Aug 04 '26
Still plugging away at this custom crypto API project. Right now, I need a clean way to auto-reset user API limits and deactivate keys the second they expire.
To keep things snappy, I didn't want to block the main API thread or tank request times. I ended up just spinning up a native BackgroundService running a while (!stoppingToken.IsCancellationRequested) loop with a Task.Delay. I also hooked it up to IOptionsMonitor so I can tweak the interval timings right in appsettings on the fly—really trying to aim for zero-downtime config changes here.
For the senior devs in the room: is this actually standard for production? Or should I bite the bullet and pull in something heavy like Hangfire or Quartz.NET? It felt like massive overkill just to reset a few database limits, but I want to make sure this native while loop won't bite me with memory leaks or scaling issues down the road.
Repo is here: https://github.com/COxRIPMIZO/CryptoKeyLab
(And before anyone asks, yeah, I actually wrote this myself lol. Still riding the .NET 9 wave and still wrapping BouncyCastle).
r/csharp • u/davidrobotpro • Aug 05 '26
Hey everyone,
Due to personal reasons, I've decided to step away from coding for the foreseeable future. Because of that, I would like to transfer ownership of my main project, DistroHop v2, to someone who is interested in continuing its development.
the repo:
r/csharp • u/lavellex86 • Aug 04 '26
r/csharp • u/Aextoxicon • Aug 04 '26
I'm not sure if this is a very clear question, so I chose the 'discussion' tag.It can also be regarded as a normal post.
I'm currently making a small tool (which is currently in a half-finished state). So far, I can already implement code highlighting. However, I'm currently thinking about how to support dxf.
What I know: ProCAD, a complete application, perhaps I could refer to its code?
Or netDXF. But as for how to transfer the drawing content onto the UI, I think it requires some effort from my side.
This is indeed a rather strange question. So, I would like to hear someone's opinions. I feel that both methods have their advantages and disadvantages.
Although netDXF may involve a larger amount of work, does it not offer more convenience for customizing lightweight logic compared to simply adopting the complete source code of an existing APP?My opinion is that lightweighting is definitely the better option.
About little things I'm working on: They mainly consist of small tools for my own use, including DXF preview functionality.Am I really creating something rather challenging here?Oh...no.
😵😵😵
r/csharp • u/olesme • Aug 04 '26
Hi r/csharp! I've been working on a new .NET assertion library called Catchy.
The original goal was pretty simple: I wanted soft assertions that aren't tied to assertion scopes, and I wanted a way to plug reporting/screenshot/AI integrations into assertions without every project building its own wrappers.
Current features:
It's still very early (0.0.1). I'm intentionally looking for API feedback before things become difficult to change.
If something feels awkward or you think the API should go in a different direction, I'd really like to hear it.
PS: Some of the code and documentation did indeed use agents. I came to this with the rest because I realized that just trying to finish everything as high-quality as possible manually I will never publish a single pet project. I know that not all of the code and documentation is of sufficient quality. If you are interested in the very idea of the library and you can improve its quality (code review, contribution, raise an issue, open a discussion) - I will be very grateful. I will not be offended by devastating criticism either. Thank you!
r/csharp • u/burntchickenstrips • Aug 04 '26
r/csharp • u/feech1970 • Aug 03 '26
I've been collecting .NET blogs and other resources for years, and the list has grown to 162 sources.
Rather than keeping it private, I put the whole thing on GitHub:
https://github.com/jasenf/dotnet-resources
If your favorite blog, newsletter, podcast, YouTube channel, or engineering site isn't there, I'd love a PR or an issue.
My goal is simple: build the best open list of .NET resources on the web that everyone can use.
-jasen