C#

C

C#

We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.

Join

How can you tell if an object supports using?

I’m following some azure docs and it uses the code using(var cache = ConnectionMultiplexer.Connect()) I understand that it frees all the caches resources and closes the connection when it’s finished but I’m wondering if given a random class how do you know if it supports that type of syntax? Is it in the function signature or would you have to read the code to see if it defines a dispose function?

Assignment Problem

I am working with two third-party services: Pyannote AI for Speaker Diarization and Whisper for Speech-To-Text. The reason I am using Pyannote is because Whisper does not innitially support Speaker Diarization (for what I am informed about). So what I need to do, is match the Speakers from the Diarization response of Pyannote with the segments from the Transcription response from Whisper. Since both responses provide time parameters (start and stop), I am thinking to rely on them......

Generics, Constraints and a simple question

I made an Interface IParent, and a bunch of classes Param<T> where T : IParent, but I'm not able to put List<Param<IParent>> like a generic list and add in it 😦...

Generics w/ EF Core

I have an API that I don't control that looks something like this: ```cs public interface ICategorized { public int CategoryId { get; set; } } public interface ITypeA { }...

Named Pipe IPC: Protocols & Status Codes

I'm basically starting from scratch with my implementation, since I've gone way too deep with my initial approach and need something that I can actually finally work with. I'm writing an IPC implementation via named pipes. I'm open to other ideas (I don't know if anonymous pipes are appropriate here), but named pipes are definitely what I've settled on. I cannot use additional NuGet packages and I'm on .NET Standard 2.0 (C# 13, PolySharp). ...

Correct file structure in VSA web API project.

I'm building my first project with VSA architecture and would love to know if structure that I've choose is fine.
No description

✅ out vs ref keyword usage

Hello guys, can someone explain when to use the out keyword and when to use the ref keyword please. I understand that in both scenarios, behind the scene, a pointer is passed so that any change made is reflected back. I also read that ref need to be initialized before passing value as argument while out doesn't but out need to be assigned a value inside the method itself. I don't understand where one is used over the other though... can someone explain please, any use cases/best practices....

SQLite weird state managing / caching

I am working on .NET API and I have some problems with handling/saving sqlite state. Before I post all of my code, I am using EF and handling dbcontext lifecycle with DI. What is the process where the problems occur: - Start API and send one POST requet to enter something in DB (when the API is starter, sqlite created WAL and SHM files) - The entered data is visible on API website and always in DB Browser for Sqlite - Stop API...

Azure Data API Builder - Partial Match

Anyone familiar with the Azure Data API Builder how I can do a partial match filter with a string? There doesn't seem to be a filter operator for a "like". https://learn.microsoft.com/en-us/azure/data-api-builder/rest#filter...

✅ VSCode being a bitch

I used dotnet new console -n Main to generate a new c# environment in vscode, but I can't run and when I try dotnet restore to fix whatever issue I likely have, I can't restore because:
MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.
Which is obviously not right because I do have a .csproj file.. and a .sln....
No description

How i can make title bar transparent and be inside of my form

Is it possible to change the title bar of a WinForm to be trsnparent and be inside of my form? ``` __ [Form1___-|[]|X] <- this thing over here...

Mapperly Help how to map child CreateDto's?

I have a problem that I cannot solve at the moment I still don't know how to map the properties of the child CreateDto's. Mapperly documentation I didn't find anything about it or just don't understand it. If someone can guide me or help me map this so I can do this to my other entities. MapperProfile:...

Game development help

Hey guys I'm developing a board game and I don't know how to read the numbers from the dice, the dice was made in blender and animated in UNITY

Data structure in C# - Dictionary<TKey, TValue>

Hello guys, I have a quick question... I have a miss-conception, when we say the term "dictionary" ; is it just another term for a hash map/hash table? Or it just uses the idea of hash table behind the scenes? Because if I remember correctly, we also have the concept of Hash set where there (I think), it takes only one generic parameter. How does these 2 differs in terms of one is key-value and the other is just the value please, I'm a bit confused.

Quiz outputting wrong code

My code asks the questions correctly and the ascii art like I want it to, but whenever it finishes asking the questions it starts printing out the answers to the questions at the top of the console. How do I prevent this?

✅ Enums as strings on AspNetCore controller .NET 9

I have added this enum ```csharp [JsonConverter(typeof(JsonStringEnumConverter))] public enum Locale {...
No description

is there anyone who can help me to setup prometheus inside the k8s cluster

I need a help with implementing prometheus/grafana inside the kubernetes cluster

Formatting .CSS files in a blazor project

Howdy, Sitting with a blazor project, .NET 8 wasm, it got some .CSS files, like the app.css and so one. I would like to just format these files in a sane way. I'm used to frontend in JS, and where I can just use prettier and save my files in vs code and it will format the file in a nice way. The document formatter in Visual Studio works but it's so opinionated, it does the basic things like adding whitespace if missing, fixing indentation etc. But it doesn't respect blank lines. Even when they're put there on purpose to create clear structure. The vs code solution I'm used to has no issues with this, but visual studio just rips the blank lines out. I can't find any setting for this either, any tips?...

✅ Can I rearrange dll files?

I will translate GTA 5 plugins from English, is this possible?

XAML property issues

My markup apparently does nothing for Backgorund, but it does for Foreground. How does that make sense? I need help setting a selected background to the same as the non-selected ones as well as using the same hover color as my button, which apparently doesn't work for the ComboBox(Item), but it does for Button. XAML ```xml <UserControl.Resources>...
No description