C#

C

C#

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

Join

How to manually upgrade a websocket connection (preferably with a popular package like Fleck)

For authentication (this isn't a traditional web server so I planned on not using like ASP.NET, plain console). I'd prefer not creating/managing a websocket connection from scratch, but if there's no other option with C#, i guess ill have to.

EF attributes vs built-in C# keywords (like required). Differences and when to use?

Essentially what the title says. In this code ```cs using System.ComponentModel.DataAnnotations; namespace Easygym.Domain.Entities...

How can the color of this section be changed for every page?

this is a MAUI project and i dont know to change it
No description

Fetching XML files from Azure Storage Explorer sometime fails

So for work we have a Azure Storage Explorer Fileshare where the customer sends XML files. Our Job fetches files from this fileshare every ~20 minutes maybe. Some files works fine and some just straight up fails with this code ``` var xmlFileByteArray = _azureHelper.GetFileBytes(fileName, sourceDirectory); if (xmlFileByteArray is null)...

TS6385

I have met this TS6385 (JS)'(handler: (S:JQueryStatic) => void): JQuery<document>' is deprecated I have try to update Ensure jQuery Types are Up to Date but it's not solves this problem. It have problem with "ready". How could I fix it? Thank you so much $(document).ready(function () { loadDataTable();...

array exercise

i want to generate numbers that are unique and dont duplicate int[] x = new int[10]; for (int i = 0; i < x.Length; i++) { x[i] = Random.Shared.Next(15); Console.WriteLine($"{x[i]}");...

WPF : The ItemsControl border has extra lines appearing.

I am using ItemsControl with WrapPanel as the panel and have set a border for the ItemsControl. How can I make the border apply only to the content area? Right now, there is extra space beyond the content area. <Setter Property="ItemsPanel"> <Setter.Value> <ItemsPanelTemplate>...
No description

Kafka Streams .NET – Is this the right approach for merging product data from Debezium?

Hi everyone 👋 I’m currently migrating a legacy system where product information is spread across 8 different tables in a SQL Server database. 📌 Goal:...

✅ Random help

How do I get a random ulong out of Random.Next()? Random.NextInt64() seems to actually only give a random 63-bit number

Need Help With Understanding EF Core and DI in specific case

Hi! Im working on an CRUD WEB API with asp.net how should I pass database context to the subservice? Currently I have a controller that calls service method to get something and return it. FilmController receive request to save film and provides data to DataService& But I need to check if Actors are already in database and if no than I have to create one and save it to db. Here is code for better understanding. ```...

When I try to run my .NET project, the browser doesn't open, and I receive a warning in the console.

this is my launch setting. i am not able to figure out { "profiles": { "http": { "commandName": "Project",...
No description

Json Serializing And Deserializing Practice Errors

I am practicing Json Serializing rightnow, but I got stuck on this for the last day. I always get this error, and I just want 1 thing, save the ingredients, and load it. ```cs using System.Collections.Generic;...

Stomp client

*How can a C# client connect to a backend Spring STOMP WebSocket?**
I searched GitHub and only found a few outdated projects with around 20 stars, but none of them work properly....

Unexplained Duplicates in Method Signatures Query

I'm using the exhibited code to extract all method signatures from a .cs file that in this use case contains 2 declarations of the same class, but in different namespaces like this, in one file: ```cs namespace CrossCut.Cache.Api.Services { public partial class CacheServices...

Rainbow using Hex vaValues

Random question: if I wanted to make a rainbow using hex color values, how would I go about it? Surely it's not as simple as just adding 1 to the hex value and then just displaying the corresponding value as a color and then repeating, is it?

AboutView not registered?

/// App.xaml.cs ```csharp protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e);...
No description

Generated OpenAPI document uses PascalCase instead of camelCase on requestBody properties

Hello, I'm still new to .NET and I've been trying to solve this issue for 2 days now. I'm using .NET's Microsoft.AspNetCore.OpenApi package for generating OpenAPI document. It automatically serializes all model properties to camelCase, except for requestBody. I have an upload controller that receives form data: ...

Razor or React?

I would like to do a small pet project - a website. In the backend I will use ASP.NET, but in the frontend I am a complete zero. I would like to be able to show this project as a portfolio of work for the backend. Plus to understand how the frontend connects with the backend, at least on a minimal level. But I don't know what is better to use for frontend Razor Pages or React....

✅ Is there a difference when we use { get; init; } vs { get; } ?

```C# public record Person { public required string FirstName { get; init; } public required string LastName { get; init; }...