C#

C

C#

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

Join

Nested else if | help

Hi, im new to C# and am a bit confused. What is the difference between a if statsment with a nested if-else and a...

Concurrency issues - distributed system

Hey, needing some advice or pointers with a work based question that is getting heated 😂 How can we update a customer account where 1000s of orders are coming in at the same time, this needs to be as real-time as possible, we are currently seeing up to 30 seconds of DB blocking in some cases 😖...

Managed callback to native code (reverse p/invoke)

If I pass a managed callback to native code, do I need to pin the stored delegate so it does not get moved to a new memory address or is this handled by the runtime? ```cs public class MyTestClass {...

Building a Chat App with Firebase in .NET MAUI – Any Examples or Guides?

Has anyone tried to build a chat app using Firebase in .NET MAUI? I've already implemented authentication (login/register) with Firebase, but I'm facing some obstacles in setting up the chat functionality. Are there any examples or guides on how to implement it? I haven't found similar projects on GitHub. Any help would be greatly appreciated!
No description

Calculation not working

So I am struggling with the calculations in the Parts and Labor section. Previous version I had, worked calculation wise but i wasnt happy with the results. Original - where hours of labor is, it originally read Labor($). I changed it and want to input a calculation of the person putting hours of labor, ie 1, 2, or 3 hours worked and it will calculate the hours * 20.00. But I know I am overthinking and over complicating it. What am i doing wrong and how can I get it working the way i intended? (older version of .net framework as per instruction from professor) https://paste.mod.gg/arwsrwabktzk/0...
No description

WPF User control and updating binding

I've got a user control that has next and prev buttons. Clicking "next" sets a IsLoading = true, makes a request to get an image, and once complete sets IsLoading = false. IsLoading is bound to the IsEnabled property. The user control also has an index, and Next increases the index, up until it hits it's maximum index. I'd like the IsEnabled property to be bound such that IsDisabled = IsLoading Index == MaxIndex. I know I can introduce a new boolean, IsNextDisabled => IsLoading Index == MaxIndex....

Bank code

https://paste.mod.gg/jkuiernhqqgp/0 How can I use a while loop here?...

Thoughts about authorization

I was wondering what your thoughts about different ways of doing authorization? Custom filter Custom middleware .net auth like policy based or other… ...

Bank program help

``` using System; class Bank {...

Dotnet webapi test failing on GitHub Workflow

Hey everyone, I am currently creating a dotnet webapi and just got into unit- and integration-testing. So I wrote some test with xUnit and TestContainers. Running this tests locally with dotnet test works fine. The tests success and everything is good. Now I created a github workflow (which is also completely new to me) to automate this tests. However the webapi returns InternalServerError in the tests when running in the workflow. Could somebody please help me to find the error? The GitHub repo can be found at: https://github.com/Pierre808/NuvellAPI I added the beginning of the log message as screenshot....
No description

Designing a Scalable Booking .Net API – Best Practices & Input Needed

Hey everyone, I’m working on designing a mock booking hotels/flights API, and I want to know your go-to best practices, design patterns, and scalable architecture. This API will allow users to search, book and check status....

Generic static factories

Hello. I have the following interface: ```csharp public interface IStronglyTypedId<TValue, out TSelf> where TSelf : IStronglyTypedId<TValue, TSelf>...

Problems in Learning Backend

So It has been a great piece of time that I am trying to learn backend, I am with zero backend knowledge I have good hands on html,css,js. I also know C# and database servers sqlite and sql server I have used these with winforms I look into different tutorials for beginners but I seem to not hold on that because they they are adding a lot packages they don't bother to explain how it all works some may not tell what they are doing basically coding the stuff and not telling how it's all connected. It's not with one video it's most of them out there What I want to achieve is that I want to learn to create web applications for example I had to make a fine management system for a college I know html, css, js, c#, sqlite database...

Using IDisposable in private field

I have an an IDisposable object that I would like to turn into a private field:
using var audioEngine = new MiniAudioEngine(44100, Capability.Playback);
using var audioEngine = new MiniAudioEngine(44100, Capability.Playback);
eg:...

VS Code (C# + C# Dev Kit) Failing to Load

suddenly VS Code is failing to load the C# extensions. any tips? no changes since last success (except maybe a Windows update, idk) code block 1...

How to Structure an Angular + .NET 8 Microservices Project? (MVVM, MVC, Docker, Databases...)

I am working on a credit management project using Angular 16 for the frontend (developed with VS Code), .NET 8 for the backend (developed with Visual Studio), and SQL Server for the database. My supervisor mentioned a general MVC architecture with a backend based on microservices. However, I am confused about how to implement these architectures correctly. Previously, I worked with MVC, where everything was simple: I just created three folders (Models, Views, Controllers). Now, with Angular (MVVM) and a microservices backend, I don't know how to structure my folders and organize my code. 1-Which folders should I create in Angular (under VS Code) to properly follow MVVM?...

adding asp.net constaint on the class object field

in asp.net efcore : ```c# public class Consultation { [Key] // Primary Key...

Properties referencing their class

Given the following class example: ``` csharp class Node...

How do i make a listbox show thumbnails when I import videos into it?

can someone help me with making a listbox show the thumbnail when a file has a thumbnail? Ive been looking online and got no where.
Next