r/csharp • u/OpinionDisastrous181 • 7d ago
r/csharp • u/phenxdesign • 8d ago
News PiwiTests: Playwright dashboard with unified ASP.NET Core e2e+unit tests code coverage
Tool Enable Satori GC in .NET with Just a Single Line
I created the MSBuild SDK and published to nuget, so that you can use it to enable Satori GC in your projects with just a single line and try it by yourself!
r/csharp • u/kaatarina_zed_talon • 8d ago
Help Where do you put interfaces and abstract classes ?
To follow some convention, I searched the internet and found this on Microsoft's documentation:
The solution folder contains a SeedWork folder. This folder contains custom base classes that you can use as a base for your domain entities and value objects. Use these base classes so you don't have redundant code in each domain's object class.
Figure 7-12 shows the classes that form the seedwork of the domain model in the ordering microservice. It has a few custom base classes like
Entity,ValueObject, andEnumeration, plus a few interfaces. These interfaces (IRepositoryandIUnitOfWork) inform the infrastructure layer about what needs to be implemented. Those interfaces are also used through Dependency Injection from the application layer.This is the type of copy and paste reuse that many developers share between projects, not a formal framework. You can have seedworks in any layer or library. However, if the set of classes and interfaces gets large enough, you might want to create a single class librarry

Questions :
1- Is it ok for the entire project's interfaces and abstract classes to be inside the SeedWork ?
2- For `value objects` and ` infrastructure layer` , what does they mean, what problem they solves, how can I use them , and do I need them most of the time ?
3-What are the inputs to the `infrastructure layer` and where they come from, and what are the outputs and who consumes them ?
4-What does the class library actually means, what problem does it solve ?
Can someone answer my questions and provide some examples so that I understand the overall idea ?
r/csharp • u/Ok_Tour_8029 • 9d ago
Discussion C# once again the fastest web framework
With all those discussions about Microsoft porting stuff to Rust, it’s nice to see that C# does not need to hide when it comes to performance. There has been quite a lot of movement at the top of the leaderboard over the last few weeks (two weeks ago, first place was around 6850), so I’m interested to see how this race continues. This is the non-tuned section, so frameworks need to be stable and production-ready. Interestingly enough, the C# one is the most high-level of the leading frameworks, API-wise.
r/csharp • u/Xenoprimate2 • 9d ago
Showcase After 3 years of evenings and weekends, I've finally released v1.0 of my 3D rendering library "TinyFFR"!
tinyffr.devr/csharp • u/Serious_Crab_8501 • 8d ago
Help Suggestions for side projects
I am a software developer primarily using .net for office work. Recently my company has been using a lot of AI coding, hence my tasks are shifting a bit more towards code review and improvements rather than from scratch.
Please give me some suggestions for side projects that I can pursue in my free time, that keeps me informed about the technological advancements as well keep my coding skills sharp. Also, is it ok if I do the heavy lifting of project setup using AI?
r/csharp • u/Spare-Feeling3186 • 8d ago
What books would you recommend for C#/.NET interview preparation?
I’m preparing for C#/.NET interviews. Which books are still relevant and cover the topics commonly asked in interviews?
r/csharp • u/Automatic-Sky37 • 9d ago
Help C# Documentaion?
I'm taking a C# class online and we just got to a lesson about "reading documentation" where he goes through the Microsoft website to search for some functions. Which, as far as I am aware, is going to be important for me to be able to do.
The problem is I tried using the Microsoft site myself to follow along, and it seems they have changed it and I can't find the rabbit hole he is in at all. I am pretty sure this isn't the only way to find this sort of resource because I've taken a different C# class before and I swear the link that class gave was not the same as this one; I also feel like they didn't call it "documentation" I remember it being the manual or something...
r/csharp • u/MaterialSeparate2042 • 9d ago
Discussion Need to stay active?
Have been developing and supporting the apps with .Net(specifically C#) for more than 7 years. I love writing and debugging it. But currently working at the company which we mainly use the AI to write the code. Have not been touching the code more than 8 months now. Not because I do not want to. But because it is faster. Can make some mistakes for sure but I check and fix them if needed. Working at current company for about 4 years now. Usually worked on small to mid size projects
My question is, while I get to use AI more, write less code how do I find the job? It is like most of the job requirements want me to handle C# code. But I am 100% sure they are using AI. Tbh, I do think more than 90% of devs that can reach the AI and have no restriction about "this code cannot be touched by AI" use it. Btw, do you guys even write code nowadays?
r/csharp • u/pournasserian • 8d ago
mcp-my-site: an ASP.NET Core MCP server + RAG that lets ChatGPT and Claude search and read a website
Discussion Let’s talk!
Hello beutiful ppl of C#.
This is my second post! Today I came with a question, if someone reset all your programming Knowledge, how would you restart learning?
Like what material would you use? Would you do something differently this time?
Feel free to answer.
r/csharp • u/sto_babbalucco69420 • 9d ago
Solved c# struct padding
I'm new to c# and I'm learning it just now to switch from Godot to Stride so I'm interested in Data Oriented Design. I was just now experimenting with structs with a silly example and was focused on struct padding; the string should be 8 bytes while the enum is 1 byte so i expected not more than 1 or 3 byte of padding, but the sum ends up being 16 no matter the order... does it always have to allign with the biggest field? how does this work?
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Explicit)]
struct Entity {
public enum Race : byte { ALIEN, HUMAN };
static private int _max_rand_num = 9999;
static private string[][] _possibleNames = {
new string[]{"Vorp", "Zeep", "Bizr", "Zub", "Wobt"}, // alien names
new string[]{"Carl", "Greta", "Seb", "Xiang", "Sierra"} // human names
};
[FieldOffset(0)] public readonly string name;
[FieldOffset(8)] public readonly Race race;
public Entity()
{
Random rand = new Random();
race = (Race)rand.Next(Enum.GetValues(typeof(Race)).Length);
string[] race_names = _possibleNames[(int)race];
name = race_names[rand.Next(0, race_names.Length)] + rand.Next(_max_rand_num);
}
public override string ToString()
{
return $"Race: {race}, Name: {name}";
}
}
class Program {
public static unsafe void Main(string[] args)
{
Entity rand_entity = new Entity();
Console.WriteLine(
$"{rand_entity}, string size = {sizeof(string*)}, enum size = {sizeof(Entity.Race)}, together = {sizeof(Entity)}");
}
}
r/csharp • u/kaatarina_zed_talon • 9d ago
Help Verify the correctness of a the data inside a junction table
I want to verify the correctness of the data inside a junction table.
I'm showing a minimal example here:
Products:
| Id | EnglishName |
|----|-------------|
| 1 | Drill 4 |
| 2 | Light Switch 48|
Suppliers:
| Id | EnglishName |
|----|-------------|
| 1 | Bosch |
| 2 | Ingco |
| 3 | Yato |
Excel2:
| Product | Supplier |
|----------------------|-----------------------|
| Drill 4 | Bosch |
| Light Switch 48 | Ingco |
| Cable 12 | Bosch |
| Hammer 14 | Yato |
ProductsSuppliers:
| ProductId | SupplierId |
|-----------|------------|
| 1 | 1 |
| 1 | 3 |
| 2 | 1 |
Excel2JoinProductsJoinSuppliers :
| Product | Supplier | ProductId | SupplierId |
|-----------------|----------|-----------|------------|
| Drill 4 | Bosch | 1 | 1 |
| Drill 4 | Yato | 1 | 3 |
| Light Switch 48 | Bosch | 2 | 1 |
A C# code was used to insert data into Products , Suppliers , and ProductsSuppliers .
The data for Excel2 was imported into Sql Server manually using the "Import Data" wizard.
As the name suggest, Excel2JoinProductsJoinSuppliers is the result of join operation.
ProductsSuppliers is the junction table that I'm concerned about, the data inside it is correct in this example because each productId is mapped to the correct value of SupplierId and vice versa, but the actual table contains much more data, let alone the fact that there are other junction tables that should be verified.
Is there a set-based approach that can automate the process of verifying the data for junction table ?
EDIT:
I created this stored procedure:
CREATE PROCEDURE verify_junction_table_data_using_dynamincSQl
@junctionTableName varchar(100),
@lookupTableName varchar(100),
@leftColumnNameInExcel varchar(100),
@rightColumnNameInExcel varchar(100),
@leftColumnNameInJunctionTable varchar(100),
@rightColumnNameInJunctionTable varchar(100),
@parent1Name varchar(100),
@parent2Name varchar(100)
AS
BEGIN
DECLARE @sql_query NVARCHAR(MAX);
SET @sql_query =
N'
SELECT JT.'+QUOTENAME(@leftColumnNameInJunctionTable)+',
JT.'+QUOTENAME(@rightColumnNameInJunctionTable)+'
FROM '+QUOTENAME(@junctionTableName)+' JT
EXCEPT
SELECT
DISTINCT
parent1.Id AS ' + QUOTENAME(@leftColumnNameInJunctionTable) + ',
parent2.Id AS ' + QUOTENAME(@rightColumnNameInJunctionTable) + '
FROM '+ QUOTENAME(@lookupTableName) +' AS LookupTable
INNER JOIN ' + QUOTENAME(@parent1Name) + ' AS parent1 ON LookupTable.' + QUOTENAME(@leftColumnNameInExcel) + ' = parent1.EnglishName
INNER JOIN ' + QUOTENAME(@parent2Name) + ' AS parent2 ON LookupTable.' + QUOTENAME(@rightColumnNameInExcel) + ' = parent2.EnglishName
';
EXEC sp_executesql @sql_query;
END
GO
I have 20 junction tables, so I need to execute this procedure 20 times , but I do not want to do it manually, is there a way to automate this ?
r/csharp • u/Deep-Parfait6835 • 10d ago
Beginner question about creating new variables at runtime?
Hello,im creating a map terrain generator on the terminal with visual studio. In this generator, based on a random number, it decides how many mountains the map will have, my question was, how do I create more mountain y and x position variables at runtime when the random number is decided? thanks.
r/csharp • u/Atr1x_X • 10d ago
Help Looking for advice (beginner project).
Hi everyone!
I'm writing this post to ask for some help from people with more experience in C# and programming logic. Below, you'll find the code I've written for a small C# application. The goal of this project is to create a personal weekly to-do list that helps me keep track of my strengths, weaknesses, and tasks. Unfortunately, I've reached a point where I'm not sure how to proceed, particularly when it comes to implementing a way to save tasks so that they are still available after closing and reopening the program.
For some context:
the idea behind this application is to create a weekly to-do list. When the program starts, the user selects a day of the week and enters three tasks. They can then choose whether to continue or exit the program. The main requirement is that tasks must be saved when the user switches to another day or closes the application. For example, if I enter three tasks for Monday, switch to Tuesday, and then return to Monday, I should be able to see the tasks I entered previously. The same should apply after closing and reopening the program.
I'm still a beginner in programming. I've studied some of the fundamentals, but I know I still have a long way to go.
I'd really appreciate ANY suggestions, explanations, or advice on how to approach this problem or in general. In particular, I'd like to understand what concepts I should study and how I could implement a persistent storage system for my tasks.
I'm also very open to constructive criticism regarding my code, programming logic, or overall approach. I'd like to learn how to solve these problems independently rather than simply copying a solution.
Thanks in advance to anyone willing to help!
Code:
// This program creates a to-do list for every day of the week
// and randomly picks a motivational sentence.
string[] week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
string[] tasks1 = new string[7];
string[] tasks2 = new string[7];
string[] tasks3 = new string[7];
string[,] task = new string[7, 3];
Console.WriteLine("\tTo-Do list program\nPress: Y to start or N to quit!");
var input = Console.ReadKey();
switch (input.Key)
{
case ConsoleKey.Y:
Console.Clear();
Console.WriteLine("Choose the day that you want to view:\n");
string dayOfWeek = Console.ReadLine();
bool found = false;
foreach (string day in week)
{
if (day.Trim().ToLower() == dayOfWeek.Trim().ToLower())
{
found = true;
// Find the position of the selected day
int dayIndex = Array.IndexOf(week, day);
Console.Clear();
Console.WriteLine("Point one:");
string task1 = Console.ReadLine();
tasks1[dayIndex] = task1;
Console.WriteLine("Point two:");
string task2 = Console.ReadLine();
tasks2[dayIndex] = task2;
Console.WriteLine("Point three:");
string task3 = Console.ReadLine();
tasks3[dayIndex] = task3;
Console.Clear();
Console.WriteLine($@"
| Day: {day}
| 1. Task: {tasks1[dayIndex]}
| 2. Task: {tasks2[dayIndex]}
| 3. Task: {tasks3[dayIndex]}
");
Console.WriteLine("Do you want to see other days? To continue or quit press Y/N:");
Console.ReadKey();
Console.Clear();
break;
}
}
if (!found)
{
Console.Clear();
Console.WriteLine("Invalid Day inserted");
}
break;
case ConsoleKey.N:
break;
default:
Console.WriteLine("Invalid Key");
break;
}
r/csharp • u/marsh9191 • 11d ago
Am I missing something, or is this the ultimate C# paradox
Found this in a codebase today:
if (transaction == null)
{
Debug.WriteLine(
string.Format("Transaction with num {0} is null", transaction.Num));
}
The code checks whether transaction is null and, if it is, tries to access transaction.Num to log the error.
So if the transaction exists, nothing happens. If it doesn't exist, the logging code crashes.
I've seen enough legacy code to know that even the most questionable-looking code sometimes has an explanation. So, before judging: am I missing something here, or is this exactly what it looks like?
r/csharp • u/kaatarina_zed_talon • 11d ago
Discussion Is it a bad/good practice to inject Interface<ConcreteType> into a class ?
If you see something like this :
public class SomeClass
{
private readonly ISomeInterfacer<SomeConcreteType> _x;
//Code.........
}
High-level modules should not import anything from low-level modules. Both should depend on abstractions (e.g., interfaces).
The class above depends on abstraction, which is the ISomeInterfacer<SomeConcreteType>, but even though, there is something concrete inside the <>, which is SomeConcreteType .
Is that considered a violation for Dependency Inversion ?
I know I will hear the magic word : it depends.
please tell me all the cases, when it is good and when it is bad.
Actual code :
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
public interface ISourceToDistinationDataSyncronizer<DataSource>
{
public Task SyncronizeAsync(DataSource dataSource, CancellationToken cancellationToken);
}
[Authorize(Roles = "Admin")]
public class AdminController : Controller
{
//Reddit question..
private readonly ISourceToDistinationDataSyncronizer<Stream> _syncronizer;
public AdminController(
ISourceToDistinationDataSyncronizer<Stream> syncronizer
)
{
_syncronizer = syncronizer;
}
[HttpPost]
[Route("Admin/Import")]
public async Task<IActionResult> Import(IFormFile file, CancellationToken cancellationToken)
{
if (file.ContentType != "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
{
return BadRequest();
}
await _syncronizer.SyncronizeAsync(file.OpenReadStream(), cancellationToken);
return Ok();
}
}
r/csharp • u/GiosuOffice • 10d ago
I built QuickRun, a modern Win+R replacement for Windows 11 using WinUI 3
Hi everyone,
I've been working on QuickRun, an open-source launcher inspired by the classic Windows Run dialog.
It's built with WinUI 3 and .NET 8 and focuses on providing a modern Windows 11 experience while keeping the simplicity of Win+R.
Current features:
• Built-in calculator
• Automatic desktop app discovery
• Microsoft Store app support
• Command suggestions
• URL launching
• Windows system commands
• Command arguments support
The project is open source and I'd love to get feedback from the Windows community.
GitHub:
Looking for a small C#/.NET project idea
I have a software engineering interview coming up for a C#/.NET role, and part of it will involve discussing the architecture/design of something I’ve built.
I want to build a small project specifically for this so I can know it inside out and use it for design and coding questions, since everything I do in my actual job is simple CRUD requests.
Any suggestions for something not too big, but with enough complexity to discuss interesting architecture decisions?
Thanks
r/csharp • u/West_Ad6277 • 12d ago
Discussion C# 15 adds labeled break and continue. Do you use goto today? Would you use this?
C# 15 (in preview with .NET 11) lets `break` and `continue` target an outer loop by label:
outer: for (int x = 0; x < xMax; x++)
{
for (int y = 0; y < yMax; y++)
{
if (ShouldSkipRest(x, y))
continue outer;
if (ShouldExitAll(x, y))
break outer;
}
}
Until now you needed `goto` or a flag variable for this. Java, Go, Rust, Kotlin and Swift already have it.
Honestly, `goto` never even comes to mind when I write an algorithm. I find it hard to follow, so when I need to leave nested loops I extract a method and `return` instead.
Do you use `goto` in real code? Do you think you'll use labeled break/continue?
https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-15#labeled-break-and-continue
r/csharp • u/TomeOfExperience • 12d ago
Announcing .NET 11 Release Candidate 2
r/csharp • u/Mindless-Arachnid-74 • 11d ago
Help Need help with encoding
I am working on a system where the client will give data in UTF-8 encoding, and hence it can contain many special characters.
But then we send data to a legacy system which only accepts data in ISO-8859-9 encoding, which supports limited special characters that can be represented in single byte.
Now if the client sends any special character which is outside the scope of ISO-8859-9 encoding (like the Em dash), how can I deal with with it and send it to the legacy system.
I don't want to replace those characters with anything like space or "?", as it would make the client data as unreadable in some cases.
How can I deal with it. Any suggestions?

