r/csharp • u/asenhae12345678 • 3h ago
C Developer here (3 years experience). Asked to program in C#. Any tips how to start?
Title.
I'm looking to learn C# but all the courses that I found online are for beginners.
r/csharp • u/asenhae12345678 • 3h ago
Title.
I'm looking to learn C# but all the courses that I found online are for beginners.
r/csharp • u/HouseOwn392 • 9h ago
So I’ve kept been told AI is the next step and I need to keep up with it but I’ve never really know where to start. I know how to use ChatGPT and Claude on my web browser that’s it.
So I’m curious as to what Csharp developers really use for their AI workflow and are there any tutorials out there that are solid and I can learn.
Edit: what’s up with the downvotes on my fellow AI users? Yall got a thing against AI?
r/csharp • u/shanewas726 • 12h ago
r/csharp • u/Top_Marionberry_4413 • 16h ago
I did it initially because Helix seems to not want to add plugins to their editor, making it not very extensible, which is a shame. And Helix lacks a lot of features that would be useful.
Dependency-free (aside from NLua) architecture, no Terminal.Gui library dependency, written from scratch with C#.
r/csharp • u/marsh9191 • 20h ago
Today, I stumbled upon a 100-line unit test. Due to my inability to understand the name AreMatchingGuestsNotRequiredUnlessTheyAreNotUnmatching, I stripped away all the noise to figure out what it was actually testing.
This is what it essentially boils down to:
[Fact]
public void AreMatchingGuestsNotRequiredUnlessTheyAreNotUnmatching()
{
// Arrange
var first = new Trn { Guests = 2 };
var second = new Trn { Guests = 2 };
// Act
var areMatchingGuestsNotRequiredUnlessTheyAreNotUnmatching =
first.Guests != second.Guests
|| first.Guests == second.Guests;
// Assert
Assert.True(areMatchingGuestsNotRequiredUnlessTheyAreNotUnmatching);
}
Here's what the test actually does:
I was quite surprised that the test name actually matches what the test does.
Or does it?
r/csharp • u/Hertzole • 20h ago
Hey all!
I've recently gotten my small utility library for source generators to a state where I feel comfortable sharing it.
The idea is simple: I want to reuse utilities for my source generators, like a library, without having to include extra dependencies. So I just generate the utilities directly into the source generator!
For regular NuGet this probably doesn't matter much, but it may matter more when developing with Unity, as I personally mostly do. In my Unity libraries I don't want to include a shared library that multiple packages may depend on and conflict with.
So what does it do?
What about assembly size?
SourceGen utils includes a trimmer that runs automatically on build (can be disabled if you want) that removes all unused types, methods, properties and fields from SourceGen Utils. It just used Mono.Cecil to go through all the method instructions to see if something is used or not. So you only include what you use!
I've made sure to include tests for nearly all generated methods to make sure they all do what they are supposed to and that the trimmer won't remove anything that you actually use.
The project is open source, licensed under MIT, and available on NuGet. I've also created documentation so you can see what it has to offer!
Feel free to give feedback on the project and maybe even use in your own generators! :)
AI disclosure: AI was used to create the method usage detection and for validating documentation, but everything else is human made!
r/csharp • u/Mob_Pilled • 1d ago
r/csharp • u/nuclearbananana • 1d ago
I've been working on Satori Insight, a desktop app for exploring .NET memory usage and GC behavior. Built with Avalonia and NativeAOT.
The initial idea was a defrag-style map of the managed heap, where each block represents a region. It grew into a profiler that combines continuous telemetry with deeper heap inspection.
Some of the features:
It supports standard Workstation and Server GC as well as Satori GC of course (see the name of the app).
It's now open-sourced at GitHub:
https://github.com/hez2010/SatoriInsight
You can try it out by downloading the binary for your platform from GitHub Releases.
r/csharp • u/harrison_314 • 1d ago
When did you first realize that C# is magic? Or when did you realize that C# is right for you?
Back in the days of the .NET Framework 4.0, I first encountered WCF, you call an interface on the client, and it executes the implementation on the server. At the time, my head was spinning because there was no code around it that was sending anything,it just happened on its own - magic.
r/csharp • u/zarkonnen • 1d ago
I recently updated my OS (Linux Mint), and this seems to have broken NuGet. JetBrains Rider gets stuck in "Loading Projects" when opening a C# (Godot) project. My
~/.nuget/packages directory does not exist and attempting to install packages via e.g. nuget install godot.sourcegenerators -Version 4.6.2 times out.
I don't know what I need to do to get this unstuck.
r/csharp • u/VCVLMNOP • 1d ago
I'm a learner and all but I wanna know if people still use IDE's like visual studio 2026 in actual serious environments, besides or maybe even with AI agentic stuff.
personally I use the latest visual studio (purple one), because I'm still learning how to program and I don't really feel like (for me at least) it's a good idea to let ai code for me just yet.
curious to know your thoughts
r/csharp • u/AMexisatTurtle • 1d ago
Hey guys, I was wondering if anyone has any advice for a beginner learning C#.
I have some coding knowledge with Javascript API with the Foundry VTT program, though I doubt that counts as much or won't help me.
Any help would be greatly appreciated!
r/csharp • u/ShadowGeist91 • 1d ago
Hello, everyone! I’ve been working on a fuzzy logic library for C# called FuzzySharper, and I wanted to show it here, as I put out the first public preview just yesterday.
I started this project a few years ago already, but I've been putting off actually publishing for the longest time, so here it goes. I've been interested in Fuzzy logic for quite a while, and I wanted to focus on usability guided by strong core architectural principles, as I found the options available both in C# and other languages to be lacking.
As to what Fuzzy Logic is: with boolean logic, you might define “young” as “under 30”: someone is young at 29, then suddenly isn’t once he's 30. Fuzzy logic lets “young” be true to a degree between 0 and 1, which can change gradually with age. You can use those degrees in rules like “IF a character IS young AND fatigue IS low, THEN roaming distance IS long.” A game could combine rules like these to decide how far a character wanders based on their age and how tired they are.
The README includes code examples showing how to define these categories, construct rules, and configure inference in the library.
The library currently includes Mamdani inference, fluent rule construction, fuzzy and boolean premises, dependency chaining, configurable operators, and several defuzzification methods. Sugeno inference is still in progress.
This is only an early release targeting .NET 10, available on NuGet under the MIT license.
Very interested to hear your feedback, the library is still in its early infancy, but still quite feature complete regardless.
r/csharp • u/Alert-Neck7679 • 1d ago
The idea is to allow setting a field / property directly from the parameter list, like this:
class MyClass
{
private int A { get; }
private int B { get; }
private int C { get; }
public MyClass(this.A, this.B, this.C)
{
// A, B, C are now holding the values that were passed as arguments
Console.WriteLine($"{A}, {B}, {C}");
}
}
MyClass instance = new(1, 2, 3);
// prints "1, 2, 3"
These constructors can allow being body-less, as long as they don't declare any normal parameters too.
Constructors were always a painful point for me, and even though for some cases you can just use records and skip them, a lot of times you want to add logic or allow different parameter lists, and then you must use normal constructors. I also don't like the primary constructors ( class Bar(int x, int y) ) syntax, which has more problems: the parameters are private fields, so if you want to have a property, you need to declare the property + declare the parameter in the primary conductor + assign the value to the property... too long.
I would love to hear your opinions about this. I build my own scripting language for my C# game engine, and i consider adding this feature to it.
r/csharp • u/ilyashulga • 1d ago
Hi everyone! I started learning C# recently and decided to build a tool called RepoMedic. It's a CLI tool that checks if a GitHub repository has essentially files(README, .gitignore, LICENSE) and gives it a score out of 100.
I set up a CI/CD pipeline with GitHub Actions and Trusted Publishing to get it on NuGet. It was really hard (especially fixing the YAML files!), but i finally did it.
You can try it here: dotnet tool install --global RepoMedic
Or check the source code here: https://github.com/ilyashulga13/RepoMedic
I would love to hear your feedback! What else should I add to the tool?
UPDATE: Thank you all for the feedback! I just released v1.1.0. It now accepts full URLs, has a colorful CLI, and checks for GitHub Actions. Update via dotnet tool update -g RepoMedic !
r/csharp • u/InformalCurious • 2d ago
Hey guys,
I am an experienced web backend developer (Laravel, DDD) who want to learn C#, ASP.NET Core and clean architecture. I searched a lot, but I didn’t find any really good materials.
Tbh, I don’t want to pay for it (because this is only a hobby of me) and I prefer written tutorials, so it isn’t easy. I tried MS’s official documentation but it’s a mess. I tried to learn even with AI, but I think I need a well-written guide.
May I get some recommendation? Where could I read about this topic? Thanks in advance!
r/csharp • u/fuzhongkai • 2d ago
I maintain TensorSharp, an open-source local GGUF inference engine built around .NET 10. I added MiniMax-M3.1-Flash support on Day 1 of its open-weight release, and wanted to share the implementation details and a few lessons from getting it running behind a .NET server.
The current implementation supports text and image input, JSON/schema responses, tool calling, conversation-cache reuse, multi-GPU inference, DSpark speculative decoding, and CPU expert offload.
For .NET applications, it exposes an OpenAI-compatible /v1/chat/completions endpoint. The model integration and serving code are part of the TensorSharp codebase.
For this model, the C# MiniMaxM3Model adapter parses and validates the checkpoint metadata and integrates the model with the runtime. It calls a native whole-model executor through a C ABI.
That executor loads the GGUF shards, builds a GGML graph for each micro-batch, and dispatches computation across the selected devices. TensorSharp’s own native code implements the M3.1 decoder, sparse-attention kernels, expert execution, and associated model features. The upstream ggml dependency is unchanged.
The performance differences below come from the attention implementation, GPU placement, and scheduling decisions. The measured GPU path uses native C++/CUDA alongside the managed .NET model and serving layers.
One of the more useful findings came from CPU expert offload.
The native executor benchmark was decoding at roughly 15–16 tokens/s, while the server using the same placement initially managed only 7.7–8.4 tokens/s.
The host-expert workers were pinned to CPU cores. With 54 workers inside a 64-core quota, they competed with the serving process’s other threads, including the .NET runtime, server GC, HTTP handling, and scheduler.
Each expert layer synchronizes at a barrier. A delayed worker could therefore hold up the whole layer, repeatedly during generation.
Reducing the default to 32 host workers gave the serving process more room and brought server decode performance closer to the executor’s rate. There was a prefill-throughput trade-off, so the worker count remains configurable.
It was a useful reminder to benchmark native compute inside the actual managed service: the best worker configuration for the isolated executor was different from the best configuration for serving requests.
I used 8× NVIDIA A40 GPUs and the same Unsloth UD-Q4_K_XL GGUF files, totaling 232.3 GiB, for both engines. This particular model is a substantial multi-GPU workload.
The comparison was against Unsloth’s llama.cpp minimax-m31 support branch at ef8f94cc. Upstream llama.cpp could not load M3.1 when these measurements were taken.
Both engines used layer splitting, F16 KV caches, and no speculative decoding for these results. They ran separately with exclusive access to the GPUs.
Measurement |TensorSharp |llama.cpp support branch
Executor prefill, 32K-token prompt |2,449 tok/s |681 tok/s
Executor prefill, 64K-token prompt |2,567 tok/s |262 tok/s
Server time to first token, 64K prompt |40.0 s |293.4 s
Server short-chat decode |26.3 tok/s |26.0 tok/s Prefill is the work of processing the input prompt. The 9.8× result applies to 64K executor prefill; short-chat generation speed was almost identical.
The long-context difference mostly comes from MiniMax Sparse Attention. TensorSharp executes attention over the selected blocks using dedicated sparse CUDA kernels. The tested llama.cpp branch expresses the selection through a dense mask and runs dense flash attention over the cache.
TensorSharp’s separate tensor-parallel mode reached approximately 41 tok/s for short-chat server decode. That mode has different memory and prefill trade-offs, and the tested llama.cpp branch did not support tensor splitting for this model.
These are early measurements from one host and one quantization. Most results use three repeats; the llama.cpp 64K executor prefill cell is a single run, while the 64K server comparison uses three repeats per engine.
Short-chat time to first token was slightly slower in TensorSharp: 0.41 versus 0.39 seconds. Functional validation has limited coverage, including an image-reading miss and generation tests that hit token limits.
The measured TensorSharp build was an uncommitted development working tree. The report documents the configuration and methodology, but the raw run records are not committed.
Links
For anyone hosting native compute inside a .NET service: how do you budget native worker threads alongside server GC and request handling? I’d be interested in approaches that have worked well under CPU quotas.
r/csharp • u/Southern-Holiday-437 • 2d ago
r/csharp • u/JumpDangerous9271 • 2d ago
I ask this due to what happened with PHP other languages are getting patches and suddenly a good amount of security issues have been discovered in JAVA, GO and Node (not a language, but a runtime I know).
I have to create a crossword in C# in VS 2022 that players can complete and the admin that can create crossword. It must have a menu including a log-in page. I am starting with near no experience with coding C# and i have a few weeks for this. Does anyone have any tips that might help? Thanks
r/csharp • u/JOnSoNaaa • 2d ago
Hi guys i need some help. so i just started my third year in cs and completely switched to linux and yesterday i started my class on Programming with paradigms and my professor is using visual studio to create Winforms .net projects or something like this i am quite new to C# world and .net especially and i don't know what to do where to write the code cause he does all those sorts of visual gui handling adding buttoms and stuff and i just downloaded rider but it does not have those gui stuff and also is quite weird to move around file structure even if we forget that code based window creation so if there is any alternative or something that will help please let me know if not it does not concern me to use rider and get used to it but if there is something that i can follow my professor better please let me know
Thanks in advance
Wannabe Systems Administrator
r/csharp • u/kaatarina_zed_talon • 3d ago
By installing Microsoft.AspNetCore.Identity and System.ComponentModel.DataAnnotations, I believe you are able to compile the following —nearly— self-contained code:
using Microsoft.AspNetCore.Identity;
using System.ComponentModel.DataAnnotations;
namespace PlayGround
{
public class SignupViewModel
{
[Required]
[DataType(DataType.Text)]
[Display(Name = "Name")]
public string? Name { get; set; }
[Required]
[RegularExpression("^
\\+
?(\\d{1,3})?[-.\\s]?(
\\(
?\\d{3}
\\)
?[-.\\s]?)?(\\d[-.\\s]?){6,9}\\d$|(^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+
\\.
[A-Za-z]{2,}$)", ErrorMessage = "Please enter a valid email address or phone number")]
[Display(Name = "Email or phone number")]
public string? EmailOrPhoneNumber { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string? Password { get; set; }
[Required]
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string? ConfirmPassword { get; set; }
}
public record RegistrationResult(bool IsSucceeded, List<string> Errors);
public class ApplicationUser : IdentityUser
{
}
public interface IAccount
{
public Task<RegistrationResult> RegisterUser(SignupViewModel SignupInput);
}
public class UserAccount : IAccount
{
private readonly IUserStore<ApplicationUser> _userStore;
private readonly UserManager<ApplicationUser> _userManager;
public UserAccount(IUserStore<ApplicationUser> userStore,
UserManager<ApplicationUser> userManager)
{
_userManager = userManager;
_userStore = userStore;
}
// HOW TO TEST THE `RegisterUser` METHOD ALONE WITHOUT RUNNING THE WHOLE APPLICATION ?
// I WANT TO TRIGGER ALL THE PATHES OF THE `RegisterUser` METHOD TO VERIFY THAT EACH PATH IS TRIGGERED WHEN IT IS NEEDED.
public async Task<RegistrationResult> RegisterUser(SignupViewModel SignupInput)
{
// PATH 1
var validationContext = new ValidationContext(SignupInput);
var results = new List<ValidationResult>();
bool valid = Validator.TryValidateObject(SignupInput, validationContext, results, validateAllProperties: true);
if (!valid)
{
// PATH 2
return new RegistrationResult(false, ["The sent data is not valid"]);
}
ApplicationUser user = new ApplicationUser();
await _userStore.SetUserNameAsync(user, SignupInput.Name, CancellationToken.None);
if (!(_userManager.SupportsUserEmail))
{
//PATH 3
throw new NotSupportedException("user manager does not support user email");
}
var _emailStore = (IUserEmailStore<ApplicationUser>)_userStore;
await _emailStore.SetEmailAsync(user, SignupInput.EmailOrPhoneNumber, CancellationToken.None);
var result = await _userManager.CreateAsync(user, SignupInput.Password);
List<IdentityError> identityErrors = result.Errors.ToList();
if (identityErrors.Count != 0)
{
//PATH 4
List<string> errorsStrings = new List<string>();
foreach (IdentityError identityError in identityErrors)
{
errorsStrings.Add(identityError.Description);
}
return new RegistrationResult(false, errorsStrings);
}
await _userManager.AddToRoleAsync(user, "Normal-User");
return new RegistrationResult(true, []);
}
}
}
This code is a part of bigger application for sure, to test that method, I run the whole application:
dotnet watch run --launch-profile https
I'm forced to do that because the input to the RegisterUser is provided by the browser, but I will not be able to trigger all the paths inside the method if I passed the data to the method using it.
Is there a way to test this method without running the whole application so that I can provide whatever data I want to the method by bypassing the client-side and the server-side validation in order to artificially trigger all the possible paths of execution ?
An applied example would be appreciated.
EDIT :
I come across the term Unit testing a lot, I'm not sure if this is what I need.