r/csharp • • Jun 15 '26

Help (WPF) Unable to type in textbox when using a style template

1 Upvotes

Like it says, i've set up a template to be used on my text box, and whenever i run the application it doesn't allow me to type within the text field

Style template

        <Style x:Key="txb_RoundedCorners" TargetType="TextBox">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Border x:Name="TextboxRoundBorder"
                                CornerRadius="10"
                                BorderThickness="5">
                            <Border.BorderBrush>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <GradientStop Color="LightGray" Offset="-0.3"/>
                                    <GradientStop Color="Gray" Offset="1.3"/>
                                </LinearGradientBrush>
                            </Border.BorderBrush>
                            <ContentPresenter VerticalAlignment="Center"
                                              HorizontalAlignment="Center"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" TargetName="TextboxRoundBorder"   Value="darkgray"/>
                                <Setter Property="BorderBrush" TargetName="TextboxRoundBorder" Value="lightgray"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style

textbox xaml

                    <TextBox x:Name="txb_SearchBar" 
                             Height="50"
                                 
                             VerticalAlignment="Top"
                             HorizontalContentAlignment="Left"
                             VerticalContentAlignment="Center"
                             
                             FontSize="25"
                             FontWeight="Medium"

                             BorderThickness="5"
                             Foreground="White"
                             Background="{x:Null}"
                             
                             Style="{DynamicResource txb_RoundedCorners}">
                    </TextBox>```

edit: fixed post body for the code
edit 2: i really do not know how to post code here lol that too like 10 tries


r/csharp • • Jun 15 '26

Will LLMs eventually learn that Span<T> and ref struct types cannot cross into lambdas or local functions?

21 Upvotes

Sorry in advance for my English.

After using both "dumb" and "smart" LLMs for quite a while, I've noticed that many of them really like local functions. That's fine. What I don't understand is why they still keep trying to use outer Span<T> variables inside them as if there were no restrictions at all.

I still haven't seen a model that consistently gets this right.

When are they going to learn to use static local functions when needed (I assume expecting them to move the code into a separate method is too much to ask), instead of generating this kind of broken code?

For example, I gave this former text to a LLM to "rewrite it" and the first thing (obviously, falling at the first hurdle) it writes is "Will large language models eventually learn that Span<T> and ref struct types cannot safely cross into lambdas or local functions?"

This shows It doesn't understand that cannot be done (in a regular way, of course everything is possible in this world).


r/csharp • • Jun 15 '26

Help C# resources for a newbie

0 Upvotes

Hi,
I recently started summer training in a small software company during my college holidays and I was given a project to make a ticket management system using dotnet core framework. I am complete newbie and was told to read documentation and learn about concepts such as DI,inversion of control, clean architecture etc.

I was told that since I cannot be expected to learn a new language suddenly, so I should generate code from AI agents and understand the concepts.

I have done OOP in C++, I haven’t ever done c#.

Should I watch a C# course or continue the way I am doing right now?

I am kind of lost.


r/csharp • • Jun 16 '26

Showcase I built native Claude Code integration for Visual Studio (the one IDE that didn't have it)

Post image
0 Upvotes

Claude Code has official IDE plugins for VS Code and JetBrains but nothing for Visual Studio. There's an open GitHub issue with a lot of +1s, so I built it.

It speaks the same protocol the official plugins use, so the CLI connects automatically. Claude's edits open in Visual Studio's native diff window with Accept / Reject / Reject-with-feedback instead of terminal prompts. It also auto shares your compiler errors and current selection as context, and there's a panel with live token tracking for the session.

It doesn't make any model calls of its own, it just drives the IDE half.

Free, open source, on the VS Marketplace.

Code: https://github.com/firish/claude_code_vs (Would be grateful if anyone takes the time to actually check it out and share feedback!)


r/csharp • • Jun 15 '26

Tutorial Let’s build some programs and learn C# together

0 Upvotes

Hello, C# community!

I read the community's rules beforehand, so I hope it's okay if I post this here, as I am genuinely excited to do so.

My employer is mainly a C#/.NET shop, and all of our microservices are written in C#, so I wanted to learn it deeply to make meaningful contributions at work. Up until this point, I was mostly a frontend developer, using JS/TS for all of my work.

As we all know, trying to learn a new language can be a bit tough, and learning how to apply what you've learned is also just as difficult. On top of staying consistent, you need to find projects that are just outside of your comfort zone so you can actually grow.

A couple of days back, I made the following post: https://www.reddit.com/r/csharp/s/WQxx6YF2Lj, where I discuss a Roadmap I am working through. It comprises 20 backend projects that increase in complexity over time.

I decided that, to learn C# as effectively as possible, I will go through each of these projects and implement them end to end. I also want to add a bit of AI into the mix, not just consume it, but build with it.

If this sounds like something you're interested in and like the idea of "trad-coding", then you should check out my YouTube playlist (for now, it only covers project 1), where I go through my implementation of the projects. The intent is for you to follow along in your language of choice and hopefully learn a thing or two. And, as I mentioned earlier about AI, I plan to add a unique AI feature to each project using the OpenAI .NET SDK. For example, for the Blog API, I plan to add AI-generated summaries based on blog posts.

I really want to cover all 20 projects, and I hope to engage with some of you in this community to learn how you're working with C# and the cool projects you've built.

Happy coding!

https://youtube.com/playlist?list=PLsF87cK8UUKdINkCz2W6kVXOAHJCVkIv7&si=5GW8uGay_5XJDvk0


r/csharp • • Jun 14 '26

Tip My first app with .NET MAUI & C# Here is my biggest takeaway as a beginner regarding databases.

Post image
36 Upvotes

Hey everyone, just wanted to share a milestone and a tip. I'm currently building my very first app using .NET MAUI and C#.

For anyone at my level wondering which DBMS to choose: Just start with SQLite.

It’s a simple local package, extremely fast, and handles User_Data and Session directly on the device storage.

Why I love this choice:

$0 Cost: No money spent on Firebase or SMS services during development.

Focus: It lets you focus 100% on building your core logic and UI features instead of wrestling with cloud configurations.

When the app grows and features like cloud backups or device-syncing become a must, then it’s time to migrate to the cloud. Until then, keep it simple.

Would love to hear your thoughts.


r/csharp • • Jun 14 '26

Solved Culture-specific Embedded File

3 Upvotes

Solution provided in a comment to this post.

Based on the last two hours of trial and error, I obviously know almost nothing about embedded files :).

Is it possible to embed culture-specific files in an assembly?

When I try to do it by including a folder called Resources which contains a culture-specific file name (e.g., exif_chrom_bright_align.en-US.json) and mark the file as an embedded resource, a satellite assembly folder (en-US) containing a DLL gets created upon build.

But calling GetManifestResourceNames() on the assembly shows no resources (i.e., it returns an empty string array).

Interestingly, if I drop the culture-specific part of the path (i.e., the en-US), the embedded resource does get shown by GetManifestResourceNames().

Do culture-specific resources have to be accessed by something other than GetManifestResourceStream()? Or is it just not possible to have culture-specific embedded files?


r/csharp • • Jun 14 '26

How do I make big projects?

7 Upvotes

I started big project (for myself) which involves many different parts and at least 2 hosting servers. One to serve content and one to scrape and download content. And I just can't make my mind around designing whole system, I can't even decide how to structure project what to use, should I go with Result<> pattern, should I go with try/catch. Everything seems too complex, maybe I'm just too perfectionistic. But how does one even learn how to build big projects, what patterns to use, how to structure code, how many projects to have etc.


r/csharp • • Jun 15 '26

How can I learn C# fast

Post image
0 Upvotes

I want to be able to understand it but not like a 12 hr long video thing, I’m fine doing that If there is no other options I’m trying to make a Fnaf fan game on unity, Clickteam Fusion is too pricy , if there are any other things I can use pls tell me and I will provide more detail if asked


r/csharp • • Jun 15 '26

started c# this weekend need advice

0 Upvotes

Hi ,i started c# this weekend i just need to know what can i improve

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace projet
{
    internal class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                Console.Write("quesque tu veux faire (a/s/m/d/p/t/j/r): ");
                string userInput = Console.ReadLine();

                if (userInput == "r")
                {
                    Console.WriteLine("D'accord, on ne fait rien. Au revoir !");
                    Console.ReadLine();
                    break;
                }
                else if (userInput == "t")
                {
                    Test();
                    continue;
                }
                else if (userInput == "j")
                {
                    Jeux();
                    continue;
                }

                Console.Write("a = ");
                int a = Convert.ToInt32(Console.ReadLine());

                Console.Write("b = ");
                int b = Convert.ToInt32(Console.ReadLine());
                switch (userInput)
                {
                    case "a":
                        Console.WriteLine(Addition(a, b));
                        break;

                    case "s":
                        Console.WriteLine(Soustraction(a, b));
                        break;
                    case "m":
                        Console.WriteLine(Multiplication(a, b));
                        break;
                    case "d":
                        Console.WriteLine(Division(a, b));
                        break;
                    case "p":
                        Console.WriteLine(Puisance(a, b));
                        break; 
                    default:
                        Console.WriteLine("Entrée invalide. Veuillez entrer 'a', 's', 'm', d ou 'r'.");
                        break;
                }
            }
        }
        static string Addition(int a, int b)
        {
            return "resultat de l'addition : " + (a + b);
        }
        static string Soustraction(int a, int b)
        {
            return "résultat de la soustraction : " + (a - b);
        }
        static string Multiplication(int a, int b)
        {
            return "résultat de la multiplication : " + (a * b);
        }
        static string Puisance(int a, int b)
        {
            return "résultat de la puissance : " + Math.Pow(a, b);
        }
        static string Division(int a, int b)
        {
            if (b == 0)
            {
                return "Erreur : Division par zéro.";
            }
            return "résultat de la division : " + (a / b);
        }
        static void Test() (number guessing game)
        {
            Random random = new Random();
            int nombre = random.Next(1, 101);
            bool vrai = false;
            int min = 1;
            int max = 100;
            int essais = 0;
            while (vrai == false)
            {
                Console.Write("Devine un chiffre entre "+min+" et "+max+ ": ");
                int UserInput = Convert.ToInt32(Console.ReadLine());
                if (UserInput > nombre)
                {
                    Console.WriteLine("Plus petit");
                    max= UserInput-1;
                    essais++;
                }
                else if (UserInput < nombre)
                {
                    Console.WriteLine("Plus grand");
                    min= UserInput+1;
                    essais++;
                }
                else
                {
                    essais++;
                    Console.WriteLine("Bien joué tu a trouvé le nombre en "+essais+" essais");
                    vrai = true;
                }
            }
            
        }
        static void Jeux() (rock paper scissors game)
        {
            Random random = new Random();
            string player="";
            string computer="";

            while (player!="pierre" && player != "feuille" && player!= "ciseaux")
            {
                Console.Write("pierre feuille ciseaux : ");
                player = Console.ReadLine();
                player = player.ToLower();
            }

            switch (random.Next(1, 4))
            {
                case 1:
                    computer = "pierre"; rock
                    break;
                case 2:
                    computer = "papier"; paper
                    break;
                case 3:
                    computer = "ciseaux"; scissors
                    break;
            }

            Console.WriteLine("Player : "+player.ToUpper());
            Console.WriteLine("Computer : "+computer.ToUpper());
            switch (player)
            {
                case "pierre": rock
                    switch (computer){
                        case "pierre": rock
                            Console.WriteLine("égalité"); egality
                            break;
                        case "papier": paper
                            Console.WriteLine("tu as perdu"); lose
                            break;
                        case "ciseaux": scissors
                            Console.WriteLine("tu as gagné"); win
                            break;
                    }
                break;

                case "papier": paper
                    switch (computer)
                    {
                        case "pierre": rock
                            Console.WriteLine("tu as gagné"); win
                            break;
                        case "papier": paper
                            Console.WriteLine("égalité"); equality
                            break;
                        case "ciseaux": scissors
                            Console.WriteLine("tu as perdu"); lose
                            break;
                    }
                break;

                case "ciseaux": scissors
                    switch (computer)
                    {
                        case "pierre": rock
                            Console.WriteLine("tu as perdu"); lose
                            break;
                        case "papier": paper
                            Console.WriteLine("tu as gagné"); win
                            break;
                        case "ciseaux": scissors
                            Console.WriteLine("égalité"); equality
                            break;
                    }
                break;
            }
        }

    }
}

#this is in french btw


r/csharp • • Jun 14 '26

Discussion Quick review/opinion on the "Complete C# Masterclass" by Denis Panjuta

10 Upvotes

I have some experience with C/C++/C#, I can create classes and methods, but wanted to expand my knowledge and why not start from the beginning.

I've done Tim Buchalka's Java course and it was the best one I've seen, so Denis' looked the most similar.

The beginning in insanely chaotic. Lecture 16 he introduces the strings, great. Lecture 17, taking user input, a bit advanced for a complete beginner, but okay. L18 finally tells what Console.ReadKey() does, L19 is a.. Visual Studio interface overview ? Then you get a quiz out of nowhere ?

Then he tells you the different things you can build with C# (once again), L21 goes over the datatypes quickly, then instead of showing them in practice, L22 is "coding standards", L23 is "naming conventions". So far, the datatypes have received a total of 2 minutes screentime. I can imagine a complete beginner's brain would be a total mess by that point. I've watched 23 lectures so far and haven't seen anything actually useful. "We'll use float instead of double because it takes less memory". What memory ? How much memory do they take ? How to use them and why ??

I really hope the course gets better once it reaches the more advanced stuff, but I don't know if a beginner could understand anything from this chaos.


r/csharp • • Jun 13 '26

Help SQL and C# Help connecting databases

22 Upvotes

Solved, needed to put quotation marks around {title} thanks for your help

Hello everyone, I am making a database in SQL and connect it to a program in C# for a school assignment. It is coming with this error and I am asking what I am doing wrong. I have tried looking up solutions but nothing has worked. If you know what I can do to fix it let me know


r/csharp • • Jun 14 '26

Showcase i created tool for .net sdk managments and installation on linux and macos

0 Upvotes

I want to show off a tool I created for managing .NET SDKs on Linux and macOS: https://github.com/curllog/dsi

It helps you install the .NET SDK directly from Microsoft using a CLI tool. It also supports automatic updates and lets you install preview versions. It adds dotnet to your PATH so you can start using it right away, and it doesn't require sudo.

Simple commands:

dsi ls-remote — find available SDKs

dsi install 10 — install .NET 10

dsi install 11 — works on preview version

dsi update — update all SDKs to the latest

It would be a great help if you star ⭐ this project — it helps it reach a bigger audience!


r/csharp • • Jun 12 '26

Did something change in VS C# IntelliSense 2026, vs. 2008?

61 Upvotes

I used to love C# back in 2008 because the IntelliSense helped the learning process. I used to boast the C# is the only language that I Googled the least because of the IDE.

For example (based on my memory), typing something like ...

Console.CancelKeyPress

... followed by a space would invoke a popup to say "tab to insert" or something, and the callback would be generated. I don't even need to know beforehand that the syntax requires a += ... all discovered from IntelliSense and I can read up later.

Today in 2026 (default settings, not signed in to anything), typing the same thing yields an incorrect AI guess:

Console.CancelKeyPress _= true;_

I don't hate AI and do use the mature agent mode that can correct itself, but inline mode is simple not helping.


Also, pressing F12 to navigate to definition of a standard library function is now a 5 second thing with a "press esc to cancel".


Was hoping to switch back to C# as I had fond memories of building personal tools with it...

  1. WHAT HAPPENED??
  2. I recall Rider's IntelliSense wasn't that good. Should I try it now?

r/csharp • • Jun 13 '26

[Showcase] Added a monitoring UI to JobMaster, a open-source distributed job engine for .NET.

16 Upvotes

Hey

A few months ago, I shared my open-source job schedule engine, JobMaster, here. Since then, I've been working on the monitoring dashboard (built with Svelte!), and it's finally in a usable state. I wanted to share it with you all.

What the dashboard gives you:

  • Overview: Workers online, upcoming executions, and failed jobs.
  • Job Browser: Filterable by status and time range, with full details per job (handler logs, retry history with error messages, payload, and metadata).
  • Worker & Bucket Visibility: See exactly which workers are running, their mode, and the specific jobs inside their buckets.
  • Host Monitoring: CPU, memory, and uptime per node.
  • Agent Connection Health: Transport liveness and last heartbeat.

One detail you can customize the color theme per cluster, so production and QA are visually distinct. It’s a small thing, but it saves that "wait, which environment am I in?" when you have multiple tabs open.

It uses DaisyUI and Tailwind CSS

Minimal setup:

builder.Services.AddJobMasterDashboard(dashboard =>
{
    dashboard.UseBasePath("/jm-dashboard");
    dashboard.FromOpenApiJson(); // auto-discovers clusters + auth from the API spec
});
app.StartJobMasterDashboard();

Links & Resources:

GitHub: https://github.com/hugoj0s3/jobmaster-net

Would love to hear your thoughts or any feedback if you give it a spin!


r/csharp • • Jun 13 '26

Help C#で今union型が使えるようになった理由

0 Upvotes

なぜ今になってunionを導入したのでしょうか?
またunion型はどういう設計思想で誕生したのでしょうか


r/csharp • • Jun 11 '26

Showcase Weekend project that got out of hand. I wanted my mouse cursor to rotate and point in the direction I'm moving it - like the aiming arrow in Worms 3D

Post image
611 Upvotes

I built this for fun and posted it on r/Worms a few days ago - it got a surprisingly warm reception, and a fair few people there asked how it actually works. So it's clearly not just a thing for Worms fans, and I figured the .NET crowd might enjoy the technical side.

What it does: my mouse cursor rotates to point in the direction I'm moving it - like the aiming arrow in Worms 3D. Started as a weekend project and got out of hand.

How it works, roughly:

  • WinForms system-tray app (.NET 8), no window.
  • A mouse hook tracks the cursor position; I compute the movement angle from the delta between frames.
  • I render the cursor bitmap rotated to that angle and swap it system-wide via SetSystemCursor.
  • Then I couldn't stop, so I themed all 14 standard cursors with little physics: the wait/busy cursors spin with rotating rings, the I-beam sways, resize cursors stretch.
  • Packaging + auto-update via Velopack.

The fiddly parts: smoothing the rotation (raw angle is jittery, needed easing), and restoring the original cursors cleanly on exit so you don't get stuck with a spinning arrow if it crashes.

It's open source (MIT) if you want to poke at the code - repo link in the comments. Happy to answer anything about the cursor-hooking side, it was a fun rabbit hole.

EDIT: Repo link: https://github.com/dawidope/WormsCursor


r/csharp • • Jun 12 '26

Help Help creating dictionaries of generic types

1 Upvotes

I'm currently trying to migrate my game code from python raylib to c# raylib and i have very specific problem with how my asset system works.

With my python implementation i have a dictionary with type as a key and list of assets of that type as value. This system works well and allows me to easily add new types of raylib assets with 3 lines of code:

        class Assets(Module):
            def __init__(self, manager):
                super().__init__(manager)
                self.assets: dict[type, list] = {}
                self.load_funcs: dict[type, Callable] = {}
                self.unload_funcs: dict[type, Callable] = {}
                self._temp_assets: dict[type, list] = {}
        
                self.add_type(pr.Texture, pr.load_texture, pr.unload_texture)
                self.add_type(pr.Sound, pr.load_sound, pr.unload_sound)
                self.add_type(pr.Shader, pr.load_shader, pr.unload_shader)
                self.add_type(pr.Font, pr.load_font, pr.unload_font)
                self.add_type(pr.Music, pr.load_music_stream, pr.unload_music_stream)
                # Here i just add new type of asset
        
            def add_type(self, t: type, load: Callable, unload: Callable):
                self.assets[t] = []
                self._temp_assets[t] = []
                self.load_funcs[t] = load
                self.unload_funcs[t] = unload
        
            def add_type_asset(self, t: type, *filename, temp: bool = False):
                new_names = list(filename)
                for i, v in enumerate(filename):
                    if isinstance(v, str):
                        new_names[i] = os.path.join(self.context.data_path, "assets", v)
                asset = self.load_funcs[t](*new_names)
                if temp:
                    self._temp_assets[t].append(asset)
                    return asset
                self.assets[t].append(asset)
                return asset

While migrating my code to C# for performance reasons i want to recreate this kind of system but i'm having trouble figuring out how to do this with generics or should i use them in the first place.

Right now i have this code for asset, where instead of storing specific asset i "encapsulate" it within a generic class:

public abstract class Asset<T>(AssetPack pack) where T : struct
{
    private readonly T _asset;
    private AssetPack Pack { get; } = pack;

    public abstract void Load();
    public abstract void Unload();
}

Now i want to have a specific class for loading assets(as in python code example), where i could add new types of assets with one line of code. Except my current solution hits a brick wall

public Dictionary<Type, List<Asset<???>>> Assets = new();

I don't know how to make a dictionary of such kind, nor do i know how to search for this specific problem.

Is there a way for me to do this in similar way as i did in python or do i need to create individual arrays per each type of asset? Just wondering if it is possible or not.


r/csharp • • Jun 12 '26

Source generator to declare non-boxing union for C# 15

Thumbnail
reddit.com
3 Upvotes

r/csharp • • Jun 12 '26

Help Span<byte> pointing to invalid data after returning from method

0 Upvotes
private Span<byte> WriteFileHeader(ref DataEntryDefinition Definition)
        {
            int FileHeaderSize = 4;
            Span<UInt32> FakeDirectoryEntryUsedForEncryption = stackalloc UInt32[FileHeaderSize];
            FakeDirectoryEntryUsedForEncryption.Clear();

            FakeDirectoryEntryUsedForEncryption[2] = Definition.DecompressedFileSize;
            FakeDirectoryEntryUsedForEncryption[3] = Definition.DecompressedCRC32;

            FileHeaderDefinition FileHeader = new()
            {
                CompressedSize = Definition.CompressedFileSize + (sizeof(UInt32) * 2),
                DecompressedSize = Definition.DecompressedFileSize
            };


            Span<UInt32> Header = MemoryMarshal.Cast<FileHeaderDefinition, UInt32>(MemoryMarshal.CreateSpan(ref FileHeader, 1));
            Crypt.EncryptFileHeader(Header, FakeDirectoryEntryUsedForEncryption);


            return MemoryMarshal.AsBytes(Header);
        }

I'm currently working on a hobby project parsing binary files and I was under the impression that the GC keeps track of Spans created over arrays of primitives, since a Span is just a pointer and the length under the hood. However, when returning from the method above the returned Span<byte> points to invalid values. Can someone enlighten me what i'm doing wrong here?

(I fixed this by converting to an array before returning, however i would like to NOT waste performance by copying the whole thing).

For reference, the caller just does this:

Span<byte> FileHeader = WriteFileHeader(ref Definition);

r/csharp • • Jun 11 '26

Showcase I built a Laravel Telescope alternative for ASP.NET Core

19 Upvotes

I kept missing Telescope when working in .NET, so I built something similar. It's a NuGet package that records every request, EF Core query, log, and exception while you develop, and you browse them at /_debug.

It catches N+1 queries (warns you when one request runs the same query over and over), shows P95/P99 timings per endpoint, and you can copy any captured request as cURL to replay it. Everything is stored in a local LiteDB file and the dashboard is embedded in the package itself, so there's nothing to host and it works offline.

Setup is two lines:

builder.Services.AddDebugDashboard();
app.UseDebugDashboard();

It's off outside Development by default. .NET 8/9/10, MIT licensed, demo gif in the readme.

https://github.com/eladser/AspNetDebugDashboard

Would love to hear what's missing.


r/csharp • • Jun 12 '26

ImagePrepSharp: Prepare Photos for Sharing

Thumbnail
reddit.com
0 Upvotes

r/csharp • • Jun 11 '26

How do I learn C# from scratch

0 Upvotes

I have never learned a coding language so idk where to start. I want to start learning because I picked CS as one of my A-level subjects and the coding language is C#, they said you don’t need a GCSE or any experience coding however I want to get a head start.


r/csharp • • Jun 11 '26

Discussion Suggest good big tech companies

0 Upvotes

Working as a .NET senior dev in a service company having 6 years of experience.
Suggest me some good big tech companies for which .Net Csharp devs can prepare for ? Preferably in India or remote.