C#

C

C#

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

Join

✅ How does CultureInfo works in C#?

Hello guys, it's been quite a few instances now that I came across CultureInfo. I encounted it when comparing strings and when comparing dates. What I understood about it is that, if we don't specify anything, it uses the locale system of our machine. So if our machine is set to en-us and we try to compare something with de-DE, their might be issues here? I know the "ß (Eszett)" stands for "ss" I think... so, what kind of issues might arise? If we write something like this for eg: ```C#...

Why deletion of last character in Entry not triggers observableProperty? (MVVM, Maui)

I have an input field where the user can enter numbers. When any number is typed, the model updates successfully, which I can confirm using a breakpoint. However, when there is only one character left and it is deleted, the update does not occur, and the model retains the previous number instead of updating. Why is this happening, and how can I ensure the model updates correctly when the last character is deleted? ViewModel ```[ObservableProperty]...

Appending to StringBuilder by Unicode code point?

What might be the most efficient way to append a unicode code point (int32) to a StringBuilder, taking into account I need it to work on Framework.

✅ When to use each constructor?

```cs public class InventorySlot(Item item, int quantity) { public Item Item { get; } = item; public int Quantity { get; private set; } = quantity;...

Any good guides/videos to learn Abstract Classes?

As an exercise to begin using C# I´m creating a basic text game as a Console App. But im stuck trying to understand how to use Abstract classes. Any guide or help is appreciated....

Number doesn't get printed

```cs using System; public class HelloWorld { public static void Main(string[] args)...

✅ DateOnly.TryParse Vs DateOnly.TryParseExact use cases

Hello guys, I was reading a bit about DateOnly data type. I didn't understand the difference between DateOnly.TryParse and DateOnly.TryParseExact. Normally, when we use the parse method, the string given is parsed according to our system culture? How does TryParse and TryParseExact differs?

✅ How to handle websockets?

I have this handler. I wanna save all active connections to list, is it worth it? ```cs public sealed class UserConnectionHandler : IDisposable {...

Button wont get a listener

```cs private void AttachButtonToCard(GameObject cardObj, GameObject cardButtonPrefab) { GameObject buttonObj = Instantiate(cardButtonPrefab, cardObj.transform);...

Any good guides for learning Blazor WASM?

I have opportunity to start job , but i need solid knowledge of Blazor WASM (i have 0 expirience , where i can learn it)

Project Subfolder Remains Hidden in Rider

I have a project with the following structure: ``` C:\DEVELOPMENT\CODINGAUTOMATION\CODINGAUTOMATION.METADATA │ CodingAutomation.Metadata.csproj │ README.md...
No description

✅ Rider does not recognise WebImage Helper

I have a simple crud app. I would like to add a drop-down menu and button like this tutorial https://learn.microsoft.com/en-us/aspnet/web-pages/overview/ui-layouts-and-themes/9-working-with-images I just copied and pasted this tutorial code into my source code on Rider @{
WebImage photo = null;...

✅ Mouse position in console

How can i get the mouse position in a console? I'll like to get the column and row the mouse is on and also event like click, scroll...

✅ how to load sos from JetBrains CLion bundled lldb@19

Currently, I'm encountering the error: error: this file does not represent a loadable dylib error: 'setsymbolserver' is not a valid command....

How to Automate Code Compare and Merge

Yesterday I had to manually compare 25 methods in a version 3 and 22 or so in a version 4 of the same class. Beyond Compare is always my goto, but this was complicated by the fact that the methods were ordered differently in each version. I could not get Rider's Code Cleanup to order them properly because about 22 our of 25 were overloads of the same method, with only one difference, being the type of one of the method parameters. Rider's code style file layout XAML lacks the ability to order methods by their parameters. To help using Beyond Compare, I manually reordered all the methods in each class in the same way, and this was incredibly helpful. Then I copied methods not yet in v3 from v4, and ensured the logic of all the V3 and V4 methods was the same, i.e. the result of calling the V3 method was exactly the same as that of calling the V4 method. Then I manually restored the original ordering of the overloads in the updated v3 class, so the PR review wasn't a total headache. Except to get a list of method declarations with signatures but not bodies, i.e. a list of methods in the class, I found doing everything manually more tedious but much more accurate and easier than using any AI or other tooling at my disposal. The main hurdle was when I tried using Claude to order the methods, the sheer size of the file, 1.3k lines of C#, was simply too much for the prompt and response limits of the AI assistant. I have since learned that I can upload files to Claude, which probably would have helped quite a lot with token limits for prompts and context, but without knowing to upload the file, I couldn't get Claude to get its head around doing this job....

ASP Identity <> Microsoft Entra ID

Hey guys, I'm setting up a project with a local JWT Bearer authn. I created my own User class along with a custom PasswordHasher and TokenProvider to generate JWT tokens. And then I remembered ASP.NET Identity, which provides built-in methods like _signInManager.PasswordSignInAsync, etc. My long-term plan is to migrate to Microsoft Entra ID. Is there an easy switch from ASP.NET Identity to Entra ID? Can I still use _signInManager.PasswordSignInAsync with Entra ID, or will I need to use Microsoft...

AutoMapper example projects with mapping profiles

Hi all, Rather simple question (If you can even call it that?) I'm just looking for people who have worked with the AutoMapper library to dump a link to their open-source projects here if anyone has or anyone knows of an open-source project that uses it. I already have an understanding of the very basics so dont need any teaching on how it works as such....

Repository Pattern and Clean Architecture

Whenever we perform a query, the ideal approach is to return only the necessary columns. However, whenever I see content about repositories, the SELECT is always done using the entity. In other words, the entire entity is selected from the database. In my projects, I create responses or DTOs. But DTOs are recommended in the application layer, while repository interfaces belong to the domain layer. ...

Visual Studio includes only x86 dlls in build

I have a .NET Framework 4.8 WPF project set to x64 and Prefer32Bit set to false. The library .net framework projects are also set to x64 but in the final output the dlls from the system and nuget are all x86 but my Project exe and and my libraries are x64. Does anyone have an idea how to solve and get x64 only?...

Need help Publishing / Trimming my Maui / Blazor app

Currently if I enable trimming in any way shape or form it completely breaks my app. I have a linker xml set and all my libraries set to be completely preserved in the linker. Here is a link to my CSProj file and my Linker.xml https://pastebin.com/5Pa7exw0...