C#

C

C#

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

Join

im not getting any response on these endpoints

```cs var builder = WebApplication.CreateBuilder(args); // Add services to the container builder.Services.AddEndpointsApiExplorer();...

How to fix VSCode Error/Warning for valid code

Is there something I need to do in vscode to use a newer lang version or something so that it doesn't think this is an error ```csharp interface IInterface { void Test(Action<ReadOnlySpan<byte>> callback);...

Can I use merge conflict resolution buttons in VS?

Hey everyone, I was wondering if there was a way to just approve or decline merge conflict markers with buttons in VS similar to VScode? It would be nice if the method didn't rely on being a git repo as well. I've attached images of what I mean...
No description

Othello game

i have made a othello game but when i run it i can not click on any of the tiles and i dont understand why? is it the xaml code that is wrong or is it something in the gamemanager?

Which package used to localize in .net app

I just started a new app for a project for my course but i just run into a weird thing. I was trying to include Localization in my app and when I look for which package to use in the Microsoft documentation, they still used Microsoft.AspNetCore.Localization who has been deprecated to include new culture (look to the screen below). I have installed Microsoft.Extensions.Localization but the method on the screen isn't include in this package I cant figure out if I'm missing something or there is an other way to include localization in my app...
No description

Worker service recommended folder structure / namespaces

Hi there, I used to do a lot of procedural programming. Now, I have to build an OOP C# Worker service that processes files (Extract data, create JSON/XML or write data into a DB). I already know the basics of OOP and have built some smaller Java applications. Is there a recommended or best practice folder structure or pattern, like MVC, for a Worker service?...

Data Retrieval in a SignalR Hub/Service?

I am used to repo -> service -> controller MVC models, and I do not have much experience with in-memory retrieval beyond using LinQ. Say I have a class which could have multiple queryable fields: ```...

Reccomendations for starter/intermediate c# projects

So basically, i know all the basics of C# but idrk how to apply that well. currently im trying to make a small tictactoe game just using the terminal and stuff, but i dont know what to practice from there onward. does anyone have any advice? im mainly interested in building a game, visual stuff (like maybe a 3d renderer at some point?) and also writing scripts that can interact with my browser and do niche stuff. currently most of this seems kind of hard so i want to work my way up from where i...

How to use font feature settings with FormattedText and DrawingContext in WPF

I have a custom control where we are rendering various things like images and text. We have a font that has some feature settings for different character sets. I am trying to figure out how to apply Tabular Figures (tnum) and Lining Figures (lnum) for this font when drawing the text using this font. I have found how to apply these settings using a TextBlock and the Typography.NumeralStyle and Typography.NumeralAlignment, but I am having trouble finding a way to specify these feature settings during a custom render....

TransperancyKey and Contrast Issue

Hello everyone, I am working on a transparent form application, and as you can see in the image, color distortions occur in the text. One possible solution that comes to mind is dynamically adjusting the forecolor based on the colors behind the application. However, I haven't figured out how to capture the background colors yet....
No description

Best way to have a multi-window console app

Im making a simulation of the card game Rook and I would like to have each player and the table as its individual window to follow the gameplay in realtime. What would be the best way to do this? One window can be either a real human being (locally) or a bot. I dont need internet connection, Im doing this locally.

āœ… Overriding IConfigurationManager.GetSection for integration tests in .NET 8 Minimal API

Hi all, In my application, I am optionally configuring Azure App Configuration. This is achieved by checking whether or not an endpoint has been provided in the configuration via IConfigurationManager (see code below). So far in my integration tests, I'm using WebApplicationFactory to modify the services to external services....

āœ… Can't get HTTPS to work for my api deployment.

I am following the Microsoft docs https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-9.0&tabs=linux-ubuntu step by step and I get the point where you set up nginx everything works when I'm on http, but the second i try to make anything go to https everything breaks, the connections time out and I can't get anything to work, I have no idea why. No working HTTPS ``` server {...

Static class or regular class with interface?

Hello, I've been building a QR code generator for a while. It's a simple method call QrCodeGenerator.Generate("data", options). ```c# var qrCode = QrCodeGenerator.Generate("data", new QrCodeOptions...

I got a Mvc and an a API project i want to use [Authorize] attribute in mvc is it possible?

How Could i do that i added the token validation parameters in the mvc project same as the api's i am using the api's login method it returns 200 but when i try to access to [Authorize] view it sends me 401 unauthorized i also set the access token to the httpcontext but i don't know how to make that authorized in the pages

Properties vs constructor:

Iā€™m currently creating a new project and have a class called Repository that gathers info about the system the code is running on and makes some api requests. If the class has several internal values like system status which is fetched from an api, should I run the code to fetch the status in the constructor or can I have a property getter so I can write repo.system_status to get the latest value without needing to call a function ?

can anybody tell me why people switch from platform like discord to other for developers or User ??

What specific features or improvements did Discord have that made it better than TeamSpeak for you? When you moved to Gilded, what made it appealing for your community? Was it the tools, policies, design, or something else? If you were creating a new platform yourself, what would be the most important features or fixes you'd include to attract users like you?...

Seeking Advice on Simplifying a Class with Multiple Operations on Data Pairs

This memory.cs class is a mess, is there a way to structure my code so that accessing data structures dont look so messy? Thank you in advance. https://gist.github.com/Asriela/d69bf1028644c1a3d5f5bef771727807...

Aspire project won't run if `applicationUrl` given in `launchSettings.json`

Weirdest shit ever... ```json "profiles": { "Ogma3": { "commandName": "Project",...