C#

C

C#

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

Join

C# homework

I don't know if i made a good code or not

Solution to remove previous migrations and use a new migration without dropping database.

I built a simple ecommerce platform and I already have seeded users, products uploaded and so on. But I recently made a change, where I added role based authorization. When I generated the Migration file for this change, and added it, I was getting an error. ...

Compiler warnings about unused variables

I have a simple program ```cs var a = 40; var b = a; var c = 20;...
No description

What is this "Function" called???

I am programming in unity and well.. I needed to call a bool from another script... The goal: To detect if the boolean named "birdIsAlive" in "BIRBSCRIPT" is true and if so to enable the ESC key for pausing. The issue is solved, but I can't seem to understand why this works....
No description

Multiple Selection in WPF with MVVM architect

hello everyone, good morning, good afternoon, good evening. I am implementing a ListView in WPF like this. Can you tell me the best way to implement Multiple Selection? I am using the MVVM architect for my application....
No description

overriding methods

I have multiple questions: 1) What is the benefit of declaring a base method as virtual before overriding it in an inheriting class? This is my understanding: it allows calling the override despite casting to the base class. Is this correct? 2) What is the difference between overriding a method, and hiding a method? As in, what does the new keyword do exactly?...

How can I get format warning on the console?

I'm developing a .NET C# application for Linux and I was wondering if there's some way to get the warning I get on vscode like Remove unused parameter 'Sender'IDE0060 or Name can be simplified IDE0002 on the console? I tried with dotnet format and dotnet format analyzers but those didn't printed any of those warning and they didn't fix them either.

✅ EF Core Junction Tables with seperate columns

In EF Core: I have entity X which has a list of Item Y (This will let EF Core make a junction table to represent the many to many relationship) Now as per my requirements I needed to add a Price to that junction table. So that the price only exists when and if there is a link between X and Y....

Asp.net (.net461, global.asax)

Hi - hopefully easy question but i have a legacy project im taking over. If i set output folder to bin, i can debug no worries. if i use bin/debug and bin/release, then bin/ stays empty (obv the bin/debug still gets created) but when i debug, i get dll cant be found. I thought ive always kept bin clean and use bin/debug before but now im not sure

✅ override and virtual

The book I'm reading about C# and the internet say that "you can't override a method of the base class without the virtual keyword" but I don't write virtual keyword and yet I can.. So I'm a bit confused.....

Asp.net Core bin vs bin/debug

Hi - hopefully easy question but i have a legacy project im taking over. If i set output folder to bin, i can debug no worries. if i use bin/debug and bin/release, then bin/ stays empty (obv the bin/debug still gets created) but when i debug, i get dll cant be found. I thought ive always kept bin clean and use bin/debug before but now im not sure

What are the actual downsides of using Aspire in prod, being aware it isn't supposed to be?

The company I'm working at has a product that is starting to grow and the project manager suggested making a small demo with Aspire to check out the benefits for us. We finished up a demo (more like a lite version of the product, with very toned down features) and he asked me what the issues would be if we were to just use Aspire to orchestrate everything rather than deploying to something like kubernetes since everything was working well. I couldn't really answer that question since everything Aspire related is pretty new to me as well So the main question is as stated in title, what are the downsides of doing it?...

API call hangs on mobile (.NET MAUI)

I have a .NET MAUI application that when deployed on my mobile device takes forever the actually make the API request. I have to restart the app multiple times before the request will actually go through. The API server receives the client connection but no data is ever sent. I have all the correct permissions for the mobile app. Is this a common issue with MAUI or is there an issue with the way I handle my HTTP requests?

Hello guys totally new to coding need some help

I'm 17 and just starting to learn coding with c#, if you could go back in time to my age would you recommend 1. Using YouTube and tutorials to learn 2. Focusing on going in blind with just the basics 3. Reading books and code to try and understand ...

Asynchronous batch processing (queue) in C#

Hey guys, I have some batches to process and to do so I have to send each of my batches to external APi to process. I have no experience with async programming so I simplified it a bit by using Parallel.Foreach that create thread/task for each API calling and waiting for response. The reason I dont want to call API synchronously Is that processing of one batch can take a one sec or 30min (max). With the Parallel.Foreach solution it looks it works fine but form what I read on internet it's not a good approach so I want to implement kind of async queue that will take a few items from my collection of batches starts processing and after some of them is finished replace it with another etc. I tried to came up with something using ChatGPT but it only process specified number of batches (3 in my case) and than it does nothing but even if the code is short there are lot's of new concepts for me so I have no idea how to fixed this. ```public async Task ProcessBatchQueueAsync(IEnumerable<int> batchIds) { var semaphore = new SemaphoreSlim(3); var tasks = new List<Task>(); ...

Signalr

Hi! For work I have to connect the middleware with the backend in a fast way so I ended up deciding to use signalr. I have a serverless signalr instance running in azure and an azure function for the bindings I am start with a small poc to fully understand how it's working...

Application Insights Auto Instrumentation

banging my head against the wall on this one, anyone had the same issue i'm having with auto instrumenting an asp.net core web api running on azure app service linux container? It's not attaching and i'm losing it. It worked before but now it doesn't .net 8...
No description
Next