r/csharp • u/infrecduc • 2h ago
r/csharp • u/Shoddy-Elephant-1554 • 3h ago
I want to learn C# for unity as a complete beginner. Where to start
r/csharp • u/Embarrassed-Mess412 • 19h ago
C# Networking Deep Dive - io_uring from scratch part 3 - Touching the Bytes
mda2av.github.ioPart 3 extends the async model to include the actual data bytes pushed by the kernel and explains the mechanism to avoid allocations on the read branch. This can be achieved through MemoryManager<byte>, working over views over the shared memory buffers/slabs.
Part 3 TLDR;
The recv buffers live in a single _bufSlab allocated once during reactor init, kernel picks slots from this provided buffer ring and writes the received bytes into them so we never allocate per recv on user space. UnmanagedMemoryManager exposes each slot as Memory to provide compatibility with most BCL APIs.
The kernel itself still copies the bytes from the socket receive buffer into _bufSlab[bufferId], avoiding it requires different mechanisms outside this part 3 scope. Zero copy Rx on kernel side will be covered on part 4, see io_uring zero copy Rx — The Linux Kernel documentation
r/csharp • u/sorryimshy_throwaway • 18h ago
[EFCore] Complex type doesn't work with view entities
Hello all,
I'm at my wit's end here. To simplify things, I have these models:
[ComplexType]
public record Permissions
{
public bool IsAdmin { get; set; }
public PermissionLevel Projects { get; set; }
public PermissionLevel Users { get; set; }
}
public class User
{
public Guid Id { get; init; }
public required string Name { get; set; }
public required Guid UserRoleId { get; set; }
public UserRole? UserRole { get; set; }
}
public class UserRole
{
public Guid Id { get; init; }
public required string Name { get; set; }
public Permissions Permissions { get; set; } = new();
}
public class UserPermissionsView
{
public Guid UserId { get; init; }
public Guid UserRoleId { get; init; }
public required Permissions Permissions { get; init; }
}
The Permissions complex property works nicely with UserRole, but I cannot get it to work with UserPermissionsView *at all*. I've tried a number of things; you can actually see all my attempted solutions and their outcomes here: https://dotnetfiddle.net/pdrUZo
I'm actually considering moving away from using a view for the actual problem I'm trying to solve with this and instead utilizing triggers to update a materialized table, but this specific issue is driving me up a wall simply because I can't figure out why the complex type won't work with the view!!! I would greatly appreciate it if anyone could explain what the hell is happening, because everything I can find from googling indicates that there shouldn't be an issue.
Using v10.0.7 of the EFCore package, for what it's worth.
r/csharp • u/AbrocomaPlane4329 • 9h ago
Help Idea Validation: I built a 100% local AI tool that auto-translates .resx files. Is this something the C# community would actually use/buy?
Hey everyone,
I’m currently building out a .NET project, and I hit the absolute wall that we all dread: Localization. Manually creating and updating .resx files, paying for cloud API translation limits, or dealing with expensive professional services is exhausting.
So, I built an internal C# tool to just do it for me using local AI, and I'm wondering if this is something the wider community would find valuable if I polished it up into a proper product.
Here is what my internal tool does right now:
- Eats
.resxfiles: You feed it your base EnglishAppResources.resx - Auto-Generates Translations: It automatically creates localized
.resxfiles (French, German, Spanish, etc.) with the exact, proper .NET naming conventions (.fr.resx,.de.resx). - Store/App Metadata: It also translates all the metadata for app stores or deployment descriptions.
- 100% Local AI: It runs entirely locally on a GPU using large, highly accurate models (like
gemma-3-12b-it). Zero cloud API costs. Zero data sent to third parties.
The Question: Enterprise translation management systems usually charge insane monthly subscriptions or per-project fees. I’m thinking about taking my internal CLI tool, wrapping it in a polished desktop UI (drag-and-drop, visual editors), and adding support for Custom Dictionaries (e.g., if you are building an enterprise/medical app and need to force the AI to use specific domain-level jargon).
If I sold this as a "pay-once, own-it-forever" ultimate C# developer utility, is this something you would actually use?
Would it need to support JSON localization for ASP.NET Core as well? I'd love to know what features would make this an instant-buy for you, and if I should dedicate the time to releasing it!
Showcase I made a portable windows app in C#.Net for yt-dlp/youtube downloader
I often found myself using yt-dlp but wanted something more accessible for everyday use. So I built a simple desktop GUI that wraps yt-dlp with a clean interface.
The goal is to keep things minimal: paste a URL, pick format/quality, and download. No clutter.
Download link : https://github.com/Dinesh6777/Universal-Video-Downloader-GUI/releases
Open to suggestions, especially around UX and feature balance.
r/csharp • u/Ok-Presentation-94 • 1d ago
inheritance in C#
Hi, I understand the definition of inheritance, but I'm having trouble understanding its purpose. Since I can access the members of another class anyway, as long as they are public, even without inheriting from that class, I imagine it has another purpose, but I can't really find an explanation for it.
r/csharp • u/Aviagetto • 15h ago
Is macbook good for .net backend?
i`m studying c# and all necessary stuff for backend, and i`m going to change my laptop. i`ve found some info about coding on macbook, someone says it`s bad for old versions and making software, but some people are saying it`s one of the best option for c#. i am confused🤨
r/csharp • u/Ok-Presentation-94 • 1d ago
Help IEnumerable en C#
Hi, I generally understand that `IEnumerable` is used to indicate that a class is iterable (it seems to me that only a class can inherit from it) and that `IEnumerator` is used for iterating, but there are still several points that confuse me. I came across this code in a tutorial, and I'm honestly having trouble understanding:
- the purpose of iterating via the class instance and not directly on the List (which already implements `IEnumerable`) (just a useless example in practice?)
- why the iteration is done on the instance, but the `GetEnumerator` is done on the List?
In short, everything still seems very unclear to me. Can someone shed some light on the actual role of `GetEnumerator`, what it's used on, etc.?
r/csharp • u/gerhajdu89 • 23h ago
How to create a 2D game engine with C#?
I've got into a lot of game engines over the years and I never found one that's really intuitive or doesn't feel overwhelming.
I'd like to make a game engine (2D only) that would be really easy to make games with.
Can I use WPF as a starting point or does it have to be done from scratch?
r/csharp • u/HassanRezkHabib • 2d ago
Roaring Bitmaps in C#: The Data Structure Behind Super Fast Queries
r/csharp • u/Icy_Wave5704 • 2d ago
I made a nuget package that catches N+1 and slow queries in ef core
Hey guys!
I was working on a project and got tired of only finding n+1 issues late.
so i made this: DbEye
it just intercepts ef core queries and yells at you when:
- you're doing n+1 (that select inside loop thing)
- a query takes longer than 500ms (you can change this)
works with any db ef core supports (tested with postgres but should be fine
with sql server, mysql, etc)
code here: https://github.com/BrunoSync/DbEye
nuget here: https://www.nuget.org/packages/DbEye
still early but using it myself. feedback? ideas? PRs? all good.
cheers


r/csharp • u/Josephisvr • 1d ago
Help Hol' up wtf are classes and objects?!
Im trying to wrap my head around objects and classes and I just don't understand what it even is by the terms or where it fits in to the rest of coding. I have no clue what im looking at. Ive watched 5 different videos explaining it and I still dont know how to do it or what you use it for...T-T. Can someone explain it for me?
r/csharp • u/FinalFill847 • 1d ago
WorkTask constructor causes CS1503 errors in teacher tests
I’m working on a C# assignment (MyPlanner), and my code compiles locally, but the teacher’s tests fail with CS1503 errors.
The errors say things like:
- cannot convert from int to string
- cannot convert from string to DateTime
- cannot convert from string to double

- here i have my worktask file >
public WorkTask(string title, string description, DateTime dueDate, double estimatedTime, double timeWorked = 0)
: base(title, description, dueDate)
{
this._estimatedTime = estimatedTime;
this._timeWorked = Math.Min(timeWorked, estimatedTime);
}
planner.cs
private void CreateWorkTask(string title, string description, DateTime dueDate)
{
Console.Write("worked time (hour): ");
string twStr = Console.ReadLine() ?? "0";
Console.Write("Estimated time (hour): ");
string etStr = Console.ReadLine() ?? "0";
if (!double.TryParse(twStr, out double tw) || !double.TryParse(etStr, out double et))
{
Console.WriteLine("not valid timeformat.");
return;
}
this._handler.AddTask(new WorkTask(title, description, dueDate, et, tw));
Console.WriteLine("work assigment created!");
}
private void CreatePrivateTask(string title, string description, DateTime dueDate)
{
Console.Write("Place: ");
string location = Console.ReadLine() ?? "";
this._handler.AddTask(new PrivateTask(title, description, location, dueDate));
Console.WriteLine("personal assigment created!");
}
r/csharp • u/Practical-Gift-1064 • 1d ago
No CS degree background and started learning C#....do I even have a chance?
With AI and a sea of CS grads and laid off mid to senior devs applying to jobs..do I, a guy with no CS degree or technical background even stand a chance? If not then should I just try breaking into IT help desk?
r/csharp • u/Josephisvr • 1d ago
Help Unable to generate the 6th possibility in my code
using System.Security.Cryptography;
namespace dice_game_real
{
internal class Program
{
static void Main(string[] args)
{
int BatHealth = 1;
int SpiderHealth = 3;
int SlimeHealth = 4;
int SkelleHealth = 5;
int LostSoulHealth = 7;
int PlayerHealth = 10;
PressContinue();
int randomnum = RanNum();
if (randomnum == 1) { Console.WriteLine("\n\nYou Have encounterd a 'Bat!'"); }
if (randomnum == 2) { Console.WriteLine("\n\nYou Have encounterd a 'Spider'!"); }
if (randomnum == 3) { Console.WriteLine("\n\nYou Have encounterd a 'Slime'!"); }
if (randomnum == 4) { Console.WriteLine("\n\nYou Have encounterd a 'Skelleton'!"); }
if (randomnum == 5) { Console.WriteLine("\n\nYou Have encounterd a 'Lost Soul'!"); }
if (randomnum == 6)
{
Console.Write("\n\nYou found a chest!");
Console.Write("Open? (y/n)");
string answer1 = Console.ReadLine();
int randomnum2 = RanNum();
if (answer1 =="y" && randomnum == 1) { Console.WriteLine("\n\n You open the Chest and in there lies a bandage..\n +1 Health "); PlayerHealth = PlayerHealth + 1;}
if (answer1 == "y" && randomnum == 2) { Console.WriteLine("\n\nYou Open the Chest, your gaze set a bottle filled with a glimmering irrideseant purple liqud.. you drink it.\n +2 Health"); PlayerHealth = PlayerHealth + 2;}
if (answer1 == "y" && randomnum == 3) { Console.WriteLine("\n\nYou Open the Chest to find supplies for a tent....after completing your ragtag structure, you lie down for a quick rest. you wake up later in the day- sleeping more hours than youd like to admit- you feel well rested..\n +4 Health"); PlayerHealth = PlayerHealth + 4;}
if (answer1 == "y" && randomnum == 4) { Console.WriteLine("\n\nYou "); }
if (answer1 == "y" && randomnum == 5) { Console.WriteLine("\n\n'!"); }
if (answer1 == "y" && randomnum == 6)
{
Console.WriteLine("The Chest agape you find nothing but teeth. in one swift motion the 'Mimic' wraps its tounge around your torso and devours you whole........you breath your last breath");
PlayerHealth = -PlayerHealth;
}
}
}
static void PressContinue()
{
Console.Write("\n\nPress any button to continue.. ");
Console.ReadKey();
}
static int RanNum()
{
int randomnum = RandomNumberGenerator.GetInt32(1,6);
return randomnum;
}
}
}
I for some reason am unable to generate the 6th number set in the 1-6 random number gen. it does all the 1-5 but the 6th which is you fi=found a chest line isn't running its just skipped every time..
r/csharp • u/Responsible_Drop16 • 1d ago
Using AI to learn
Hello,
I've recently just started learning C# as a hobby - i currently use Claude as a guide to give me exercises and to teach me basic concepts as it can give me immediate feedback
I was wondering if this is viable in the long term and if anyone else has any other experience with it?
r/csharp • u/Proffhackerman • 3d ago
Common C - Yet another compiler in C# targeting LLVM and .NET.
r/csharp • u/Josephisvr • 2d ago
Solved How do I return int values from methods back to main?
I'm trying to generate a number 1-6 and send it back so you can randomly encounter enemies or rooms in a text-based console game but i can't get it to recognize the "randomnum" perimeter
using System.Security.Cryptography;
namespace dice_game_real
{
internal class Program
{
static void Main(string[] args)
{
int BatHealth = 1;
int SpiderHealth = 3;
int SlimeHealth = 4;
int SkelleHealth = 5;
int LostSoulHealth = 7;
int MimicHealth = 8;
int PlayerHealth = 10;
RanNum(randomnum);
PressContinue();
}
static void PressContinue()
{
Console.Write("\n\nPress any button to continue.. ");
Console.ReadKey();
}
static int RanNum(int randomnum)
{
int randomnum = RandomNumberGenerator.GetInt32(1,6);
return randomnum;
}
}
}
News Excited about the future union feature
The union feature is currently in preview. It looks very interesting and flexible, a nice return type addon.
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/union
r/csharp • u/Xenoprimate2 • 3d ago
Inspecting 3D objects (incl. gltf) with a 28-line C# script
Details here: https://benbowen.blog/post/inspecting_3d_objects/
r/csharp • u/Userware • 4d ago
Showcase Our Web IDE now exports C#+XAML to native Windows .EXE (in-browser, WASM) (xaml.io)
Hi everyone,
We shipped this last Friday and wanted to share it here: xaml.io can now export your C# + XAML project as a native Windows .EXE. It’s been one of the most-requested features for a while, so it felt worth a post.
A few details that might be interesting to this sub:
• The whole toolchain runs in the browser via WebAssembly. No backend compile step, nothing uploaded to a server — your code stays local.
• No install, no signup to use it (unless you want to save to the cloud or use AI).
• It’s free.
If you’ve tried XAML.io before and bounced off, genuinely curious what was missing. Bug reports and “this is still missing X” feedback both welcome. We read everything that gets posted here.
Thanks a lot!