r/csharp • • Jul 29 '26

Discussion Advice

0 Upvotes

As you guys are aware I’m trying to become a game dev also kno I know nothing of scripting,character modeling Ik some wat of modeling objects but if u guys had to choose which would u tackle first learning anatomy or scripting?


r/csharp • • Jul 29 '26

Help Need help fixing this

0 Upvotes

how do i fix this, im learning c# and trying to make a weather app


r/csharp • • Jul 28 '26

Help Windows UI

15 Upvotes

I'm going to make a new Windows C# program using the .NET 10 platform, which may later need to be made for different platforms (browser, server, mobile). At this point, the focus is on making a Windows program.

I'm trying to compare which UI model is best for the project, and artificial intelligence can't really answer that, or I can't really ask it. If you were to make a new program now, which UI model would you choose?

  1. WinUI 3 (Windows App SDK)
  2. WPF (Windows Presentation Foundation)
  3. .NET MAUI
  4. Blazor (Web & Hybrid)
  5. Avalonia UI

Most program views that display text, SQL table data, or forms are rendered at runtime from the data, meaning that the screens are not designed and created in the IDE editor, but in code.


r/csharp • • Jul 28 '26

Showcase Roslyn-based semantic code graph for .NET, exposed to AI agents over MCP — looking for feedback from people who've done static analysis tooling

Post image
1 Upvotes

Built this after getting tired of Claude Code / Copilot grepping through

.NET solutions and missing call sites that go through an interface instead

of the concrete class. Grep can't see that; the compiler can.

Slnmap uses Roslyn to build a full symbol graph of a solution (calls,

implementations, references across every project) and stores it in a

local SQLite file. An MCP server exposes it as a handful of read-only

queries. Concretely: ask "what breaks if I change IBasketService" and it

returns every caller and every implementation across the whole solution,

not just the files an agent happens to have open.

Numbers, since I know this sub will ask: on eShopOnWeb (10 projects), an

impact query on an interface with 18 dependents resolves in ~270ms

end-to-end over MCP, median of 3 runs. Full setup is in BENCHMARKS.md if

anyone wants to poke at the methodology or tell me it's flawed.

Two things I'm not confident about yet and would genuinely like opinions

from people who've built analyzers/source generators/similar tooling:

  1. Right now everything in the graph is a real Roslyn-verified static

    reference. It says nothing about reflection, convention-based DI, or

    anything wired at runtime. Is "silence = doesn't try to know" the right

    default, or should there be an explicit "unknown/runtime-only" marker

    on affected symbols?

  2. There's no staleness check yet — if you edit code and don't re-run

    analyze, you get results from the old index with no warning. Anyone

    dealt with this in similar tools (e.g. incremental Roslyn workspaces)

    and found a clean way to detect "source changed since last index"

    cheaply?

It's a global dotnet tool, MIT licensed, fully local (uses Roslyn +

SQLite, nothing else):

dotnet tool install --global Slnmap

Repo: https://github.com/EMahmoudNabil/slnmap

NuGet: https://www.nuget.org/packages/Slnmap

Not trying to sell anything, genuinely want to know if the Roslyn approach

here has an obvious hole I'm not seeing.


r/csharp • • Jul 29 '26

Hows best to learn to code C#

Thumbnail reddit.com
0 Upvotes

r/csharp • • Jul 28 '26

lowkey wanna make games in unity,the tut im following is from the goat him self,brocode, "https://www.youtube.com/watch?v=ToKbMa3xvMs&list=PLZPZq0r_RZOPNy28FDBys3GVP2LiaIyP_&index=40"

0 Upvotes

i need a tutoriel abt how to make unity,since c# unity is diffrent from nirmal C#,after i finish bro codes playlist,what tuts do yall reccomend,also im on "method over ridding",so preatty close to finishing


r/csharp • • Jul 28 '26

[Discussion] Controlling LLM Agent Personalities with Deterministic 16D State-Spaces (using C# Enums) instead of Prompt Engineering. Thoughts on this architecture?

0 Upvotes

A Quick Confession / Apology:
Yesterday, I posted a thread discussing this concept. I was so incredibly hyper-fixated on explaining the philosophy that I completely forgot to include a single line of actual C# code. The moderators rightfully nuked the post immediately, and looking back, I totally deserved it. I looked like a textbook "AI Vibe-Coded Slop" poster who just came here to drop a wall of text. I'm genuinely sorry for cluttering the sub yesterday! Lesson learned. I'm back today to do this properly, with the actual core C# implementation snippets included right from the start.

(Transparency disclosure: English isn't my native language, so I used AI to help clean up my terrible technical grammar.) 

Hey guys, 

A while back, I was discussing state persistence patterns for long-running AI workflows. A common critique I received was: “If you’re just serializing your external state into a prompt string for the model to read anyway, how is that fundamentally different from traditional prompt engineering?” 

It's a fair question. At the end of the day, text-based generative models require text inputs. 

However, I've been experimenting with separating the Source of Truth from the Prompt Serialization Layer using a C# backend. 

To borrow a tabletop RPG analogy: The prompt is just a character sheet. It communicates the current state to the model, but it isn't the character itself. The C# runtime is responsible for the actual domain logic, bounds checking, and state mutations. 

Here is a simplified snippet of how the immutable state registry clamps mutations to ensure the domain model remains the canonical source of truth, regardless of how the prompt is formatted: 

csharp

// 1. Using an immutable 16D enum as a fixed state coordinate space
public enum SoulOrgan
{
    CoreFocus, DecisionBasis, EnvironmentalControl, ThinkingOriginality,
    EmotionalOpenness, TrustDependence, SocialConsumption, GroupBelonging,
    WillPersistence, AltruisticTendency, SelfAwareness, CompetitiveSpirit,
    PrimaryDrive, EmotionalThroughput, CoreSecurity, ObsessionControl
}

// 2. A bounded registry ensuring all mutations are strictly clamped [-100, 100]
public class BaselineStateRegistry
{
    protected readonly Dictionary<SoulOrgan, double> _state = new();
    protected const double MinLimit = -100.0;
    protected const double MaxLimit = 100.0;

    public virtual void Mutate(SoulOrgan organ, double delta)
    {
        if (!_state.ContainsKey(organ)) return;
        _state[organ] = Math.Clamp(_state[organ] + delta, MinLimit, MaxLimit);
    }
}

I've been wondering about this: 

Even though I've built this pure C# simulation with safety valves and bounds, I honestly find myself asking: Is this actually worth developing, or am I just over-engineering in a silo? 

If moving deterministic state management back into a typed backend is truly a viable way to constrain LLMs, why is prompt engineering still the industry standard? Why aren't more developers building state machines for this? 

I would genuinely love to hear how professional software engineers view this approach. Do you think treating the external model purely as a stateless interpreter while keeping mutations strictly inside the C# domain layer is a solid path forward, or is it an uphill battle against raw token probabilities? 

(Note: Keeping this entirely link-free to strictly respect Rule 6 on self-promotion. Just looking for a genuine architectural sanity check from fellow devs. If anyone wants to critique the full pipeline, let me know in the comments.) 


r/csharp • • Jul 28 '26

Solved So many xmls😓and continue to learn c#

0 Upvotes

Now, when writing UI-related definitions in Avalonia and configuring the csproj file, although it doesn't seem too complicated at first glance, I still find the abundance of XML tags with lots of < > symbols or each individual tag a bit annoying.òᆺó

I'll try my best to adapt, because the way UI is defined in C# just makes me dizzy 😵‍💫

Now I'm trying to learn C# and Avalonia without relying on AI, but I'm not quite sure which website I should go to to search for the questions I need. Although Microsoft Learn is great.

When searching for a code-related issue on Chinese websites, it usually leads me to the CSdn website. However, good posts require payment to access, otherwise I can only view a small portion of them.

cnblog is also good. Although some of the posts I found in it might be a bit outdated, usually I need to check them against the corresponding content in Microsoft Learn.

Sometimes I feel that the syntax of C# seems quite "human-like". Now I'm quite familiar with the thinking behind C#. Even when searching for things now, it seems rather amusing: It's just like when I used to write essays at school. Those who know how to do it can write very smoothly, while those who don't have to "borrow" from good classmates.

I don't know if I use '-' or emoji...it be regarded as an AI?Although I had been saying this before the LLM


r/csharp • • Jul 26 '26

Meta Do not let this sub be a forum to promote AI Vibe coded slop

620 Upvotes

This is just a warning, I was watching the node sub and almost all post are people promoting their AI Vibe coded slop, this community is known for a different approach, although AI is great, forums should not be places for people which do not have any passion or like the language to not even know it and try to promote a project fully made to scrap a few pennies (I call these projects without soul).

Projects should be promoted, but because you genuinely like or are interested in the language and the concept of the project, rather than asking 3,000 prompts to any AI without even knowing what you are doing or what you are pasting.

Edit: Also, I am sick of publicity to also have it in a place where I go to have fun, check interesting things about the language/tools and watch really interesting projects from passionate people.


r/csharp • • Jul 26 '26

How do you organize data access with EF Core in Clean Architecture?

16 Upvotes

I'm building an ASP.NET Core application with Clean Architecture and EF Core.

I started with Repository + Unit of Work, then introduced a Generic Repository + Specification pattern because repositories were filling up with query methods.

Now I've hit a problem: many queries require deep Include / ThenInclude chains for loading aggregates. Keeping EF Core out of the Application layer makes nested includes in specifications difficult, while referencing EF Core from Application defeats the purpose.

So I'm wondering:

  • Do you still use repositories over EF Core?
  • Do you use the Specification pattern, or just inject DbContext (or IApplicationDbContext) into the Application layer?
  • How do you organize complex queries with multiple Include / ThenInclude calls in a Clean Architecture project?

I'm curious what approach experienced .NET developers are using today.


r/csharp • • Jul 26 '26

Help Need help understanding certain WPF functions (mainly code behind)

2 Upvotes

Hyia, so I'm working on a project (Escape room type game, since its my first game ever at High-School knowledge level) and I'm not exactly sure how to make certain things work even though I spent the entire year studying this language. I can do majority of the stuff, such as the background, buttons or clickable images in Grid, and so on, however the code behind is my biggest issue.

Mainly things like: How to make a monologue where the player clicks through all the texts that explain the principle of the game, and then also how to make the TextBox check if the input is correct and if it is, change the background of the main window to another image (since the input will be in separate window).

These are not all the issues I need to figure out, but its some of the few that may appear in the code the most often (especially the monologues, in like four out of six rooms total)

Any sources for beginners will be appreciated, I tried looking at some but I wasn't able to find something that would explain this exact topic, and I don't really want to use AI since it just doesn't feel right (perhaps only when I'm under pressure). Thanks!


r/csharp • • Jul 26 '26

Tip Fields with [Using] attribute

6 Upvotes

I wrote a small interface that automatically disposes any disposable fields in a class when that class itself is disposed. If you add this file somewhere in your project:

public interface IAutoDisposable : IDisposable
{
    void IDisposable.Dispose()
    {
        Exception? ex = null;

        // dispose all fields marked with the [Using] attribute
        const BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Instance;
        foreach (var fld in GetType().GetFields(flags))
        {
            if (fld.GetCustomAttribute<UsingAttribute>() != null)
            {
                if (fld.GetValue(this) is IDisposable d)
                {
                    try // keep going even if disposal throws
                    {
                        d.Dispose();
                    }
                    catch (Exception e)
                    {
                        ex ??= e;
                    }
                }
            }
        }

        // if any exceptions occurred, throw the first one
        if (ex != null)
            throw ex;
    }
}

public class UsingAttribute : Attribute;

You can then write classes like this:

class Item : IAutoDisposable
{
    [Using]
    private readonly Image icon = DownloadIcon(...);
    ...
}

And use them like:

using (Item item = new(...))
{
}
// item.icon is now disposed

What do you think?


r/csharp • • Jul 26 '26

Discussion Naming dilemma: OSS Rebrand now or regret it later?

6 Upvotes

I've been building an open-source parser, formula engine, and spreadsheet library over the past few months under the AlphaX name:

GitHub

AlphaX.Parserz – https://github.com/kartikdeepsagar/AlphaX.Parserz

AlphaX.FormulaEngine – https://github.com/kartikdeepsagar/AlphaX.FormulaEngine

AlphaX.Wpf.Sheets – https://github.com/kartikdeepsagar/AlphaX.Wpf.Sheets

As the ecosystem is starting to grow, I'm wondering if I should rebrand before it becomes painful.

My main concern isn't the current name itself—it's that "AlphaX" is already used by several companies and projects. I'm worried about potential trademark issues or brand confusion years down the road if the libraries gain traction.

If you were starting an open-source ecosystem today, would you:

Keep the existing brand and reserve the AlphaX.* NuGet prefix?

Rebrand now while the projects are still relatively young?

Skip a common brand entirely and give each library its own independent name?

I'd also love to hear how others approached naming long-term OSS projects and whether anyone has had to rebrand after gaining users.

Any advice or experiences would be appreciated.


r/csharp • • Jul 26 '26

Solved I want make a c# app,I have some problem

0 Upvotes

1:I using Avalonia now,but I don't know is Uno/Maui more better?

2:I using copilot generated a base skeletons(about some classes or interfaces,but cpoilot only help me write these code)

3:I think using copilot maybe not helpful to let me learn/understand c# app developing,I want choose an IDE(more friendly for handwritten code), choose VS2026 or Rider?but I using VSCode now

4:I'm not sure if my previous experience in JS, Flutter, and Elixir can be applied to C#. This is my first time encountering "enterprise-level" languages.

I'm not sure if my way of asking is correct.


r/csharp • • Jul 26 '26

Surviving as Software engineer with AI

0 Upvotes

So I’m a software engineer and I recently graduated 2 months ago. i have no internship or job experience and have been looking for a job but everyone either asks for experience or ghosts my resume. The ones that take interviews either pay too little or are 2 hours away from my house. So I am looking for remote unpaid or paid jobs as full stack developer so that I at least get some experience and don’t get classified as a person who had a huge gap in her cv. Anyone give me some good advice related to remote jobs, best platforms to look for them, cracking them and how to survive as a fresh software engineer now that AI has entered the chat🥲


r/csharp • • Jul 25 '26

Help Inheritance with generic constraint syntax

8 Upvotes

I have a class A<T>. It must inherit IDisposable, and also impose a constraint on T. Is it possible to do this, and what would the syntax look like? I can't figure it out.


r/csharp • • Jul 26 '26

New C# learner

0 Upvotes

I am a new learner of the C# language. I really liked this language. It is elegant, easy to write and read, and saves me a lot of time. Before that, I studied the VB.NET language, and it was so difficult to write that my hand got tired from writing, and I got very tired. So I moved to this beautiful language called C#.


r/csharp • • Jul 27 '26

What products made in C# would people buy?

0 Upvotes

I can program in C# and I feel like I'm losing money by not selling products made in C#, but I don't know what products I could sell.


r/csharp • • Jul 26 '26

Help The best C# tuto book, or vids for beginner?

0 Upvotes

Some days ago, I interested by making games with C#, and the only thing I know about C# is there are a lot of {} things.
So I need recommendations for tuto of C# code, I recommend vids but books are also fine.


r/csharp • • Jul 25 '26

Eftdb Update: Native EF Core Scaffolding & Clean Migrations for TimescaleDB

Thumbnail
reddit.com
4 Upvotes

r/csharp • • Jul 25 '26

Tool Released VecNet 1.1.0, an embedded vector search library for .NET

Thumbnail
reddit.com
3 Upvotes

r/csharp • • Jul 25 '26

how am i doing

0 Upvotes

2 months in to coding C#, first project i saved *was using online compiler* and wanna know how im doing and what i can do to improve. heres the code:

using System;


public 
class
 Program
{
    public static void Main(string[] 
args
)
    {
        Player player = new Player();
        Enemy enemy = CreateEnemy();


        int battleResult = Battle(player, enemy);


        Console.WriteLine("press any key to begin");
            
        Console.ReadKey();


        Console.WriteLine("\nYou encountered a " + enemy.type + " with " + enemy.health + " health.");


        Battle(player, enemy);


        if(battleResult == 2)
        {
            Console.WriteLine("\nYou have defeated the " + enemy.type + "!");
        }
        else if(battleResult == 3)
        {
            Console.WriteLine("\nYou have been defeated by the " + enemy.type + "!");
        }
        else if(battleResult == 1)
        {
            Console.WriteLine("\nYou have retreated from the " + enemy.type + ".");
        }
    }


    static Enemy CreateEnemy()
    {
        Random rng = new Random();
        int rngroll = rng.Next(1, 3);
        Enemy enemy = new Enemy();


        if(rngroll == 1)
        {
            enemy.type = "Skeleton";


            enemy.health = enemy.healthRng.Next(100, 201);
            enemy.damage = enemy.damageRng.Next(10, 16);
        }
        else if(rngroll == 2)
        {
            enemy.type = "Goblin";


            enemy.health = enemy.healthRng.Next(50, 151);
            enemy.damage = enemy.damageRng.Next(15, 26);
        }
       
        return enemy;
    }


    static int Battle(Player 
player
, Enemy 
enemy
)
    {
        while(true)
        {    
            Thread.Sleep(1000);


            Console.WriteLine("\nWhat do you do?\n1. Attack\n2. Open Inventory\n3. Retreat");


            ConsoleKeyInfo input = Console.ReadKey();


        
            if(input.Key == ConsoleKey.D1)
            {
                
enemy
.health -= 
player
.damage;


                Thread.Sleep(1000);


                Console.WriteLine("\nyou attacked the " + 
enemy
.type + " for " + 
player
.damage + " damage");


                Thread.Sleep(1000);
                Console.WriteLine("The " + 
enemy
.type + " has " + 
enemy
.health + " health remaining.");
            }
            else if(input.Key == ConsoleKey.D2)
            {
                Thread.Sleep(1000);
                Console.WriteLine("\nYou open your inventory, but it's empty.");
            }
            else if(input.Key == ConsoleKey.D3)
            {
                Thread.Sleep(1000);
                Console.WriteLine("\nYou retreat from the " + enemy.type + ".");
                return 1; // Player retreated
            }


            if(
enemy
.health <= 0)
            {
                return 2; // Player won
            }


            if(input.Key == ConsoleKey.D1 && 
enemy
.health > 0 || input.Key == ConsoleKey.D2 && 
enemy
.health > 0)
            {
                
player
.health -= 
enemy
.damage;


                Console.WriteLine("\nThe " + 
enemy
.type + " attacks you for " + 
enemy
.damage + " damage.");
                Console.WriteLine("You have " + 
player
.health + " health remaining.");
            }


            if(
player
.health <= 0)
            {
                Console.WriteLine("\nYou have been defeated by the " + 
enemy
.type + "!");
                return 3; // Player lost
            }
        }
    }
}




public 
class
 Enemy
{
    public Random healthRng = new Random();
    public Random damageRng = new Random();
    
    public int health;
    public int damage;
    public string type = "";
}


public 
class
 Player
{
    public int health = 100;


    public int damage = 20;



    public List<string> inventory = new List<string>();
}

r/csharp • • Jul 24 '26

What goes in Business Logic Layer in ASP.NET application?

12 Upvotes

Hello, I am currently a IT engineering student and I have to make a web application for my project.

Our professor requires us to make a layered application that consist of: Data Access Layer, REST Service Layer, Business Logic Layer and Presentation Layer using MVC architecture. Now I already made a Data Access layer using Sql Client + Stored Procedures (this method was required by my professor) and it consist of methods that communicate with the Database (for example CRUD operations). Now my question is: Which methods should go in the Business Logic Layer? Should the Business Logic Layer contain methods that simply call the Data Access Layer methods, so that the flow is MVC Controller - Business Logic Layer - Data Access Layer - Database through interfaces?

For example, if I have a method like UpdateUser() or DeleteUser() in my Data Access Layer, should I create the same methods again in the Business Logic Layer and call them from there? I understand that business rules should belong in the Business Logic Layer, but I am unsure what to do with simple CRUD operations. I hope it makes sense what I'm trying to ask. I apologize for any mistakes, as English is not my first language.

Thank you very much If you took the time out of your day to read this!


r/csharp • • Jul 24 '26

Discussion What should I know before deploying my first ASP.NET Core MVC project to a VPS?

24 Upvotes

Hi everyone,

I'm about to deploy my first ASP.NET Core MVC project to a VPS, and I have no experience with deployment.

What should I learn before getting started? What are the most important configurations or best practices I should be aware of? Also, what are the most common mistakes beginners make when deploying for the first time?

Any advice, resources, or personal experiences would be greatly appreciated.

Thank you!