C#

C

C#

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

Join

Understanding get; set; backing field requirements.

Per the instructions (full instructions listed in the comments) "make a ToString() method that returns a string containing all job information in the following format." Job 111 Smith exterior paint 20 hours @$45.00 per hour. Total price is $900.00 ...

ScrollViewer in Avalonia DockPanel not scrolling to show all content when dynamically adding items.

Setup: - Using Avalonia 11.2.2 with MVVM pattern - Dialog with fixed height (700px) containing a DockPanel - DockPanel structure: - Header docked to Top (contains title + buttons)...
No description

CLI DotNet Testing??

I've been trying to learn about dotnet test and doing some integration tests on my endpoints. I don't have a specific goal in mind, just mashing away at code like a monkey and see what works. I was trying to get a nice, human readable output in the cli but I've been beating my head on the wall for a day now between youtube videos, etc. It's dawning on me that testing packages like xunit or mstest are meant to be used in conjuction with the Testing UI (i'm using VS Code for example) and not optimized for CLI readability. am I correct? should I abandon trying to make alterations for command line readability and just use the UI? As I type this I realize it may sound like a stupid question but please humor me. I tend to work everything in command line just out of habit and I'm curious if that's an off-the-shelf wheel I can install or if that would basically be way more customization than it is worth....
No description

Inject multiple implementations of the same interface

what's the proper way to inject multiple implementations of the same interface? ```cs public class FooBar{ public FooBar(IInterface something){ ...

Dapper to c# decimal conversion fail

When executing script where I retrieve properties, one of them being Price, it throws error: System.InvalidCastException: Unable to cast object of type 'System.Decimal' to type 'System.Double'. delivery-connector-worker | at Deserializec435cf3c-5d1c-45f9-9ce4-096c88b38636(DbDataReader) delivery-connector-worker | --- End of inner exception stack trace --- delivery-connector-worker | at Dapper.SqlMapper.ThrowDataException(Exception ex, Int32 index, IDataReader reader, Object value) in /_/Dapper/SqlMapper.cs:line 3966...

Using ` Microsoft.Extensions.DependencyInjection` in a library

I'm currently writing a wrapper around a REST API and would like to use Microsoft's DI library (normally I just use constructor injection) but I'm a bit confused as to how to do so. I've created a ServiceCollectionExtensions class and registered the services that I need: ```csharp public static class AirplanesLiveServiceCollectionExtensions {...

Learning Streamreader and async / await

where can i learn this in a good way iam learning mvc right now and i need to know this for post/get requests

JsonSerializerContext Editor Issues for AOT Compiling.

So I have set up a JsonSerializerContext that compiles correctly in AOT but in all files using the JsonContext it keeps telling me that "Default" does not exist. i checked the generated files in the obj folder and they exist. i tried cleaning out the compiled folders and restarting the editor. but the errors persist from roslyn. DonutEngine is the project that has the JsonSerializerContext file in it. ```...
No description

✅ problems with clones and programming

What was supposed to happen was for the Peashot (actor) to start inside the player actor whenever the Z key was pressed, and start with the introPeashot animation. When it's finished, repeat the mainPeashot animation. And when it touches the ground, transmit the DeathPeashot animation. (It has to move forward during all this, only stop when it touches something, stopping the movement). What caused the problem?...

✅ Need C# help

I'm learning C# on a source code for a game called Nostale, I wanted to ask if anyone who knows anything about it could drop me a line, I'd be grateful. (ON RIDER) DM ME...

Understanding Equals() method

Is there a reason my version of Equals is wrong? ```cs /* ...

✅ looking to learn blazor and i cant find anywhere good

does anybody know of any good places where i can learn blazor?

✅ Modify default code templates in Rider

I want to modify what Rider inserts into my code when I type for example a try/catch block. Rename e to ex, modify the default code in a catch block, etc. I can't seem to find the setting, can someone point out where I can find that?

Blazor vs react(NEXT.js)

I like C# and want to learn Blazor, but I'm worried it might be less popular than Next.js, or that developers might view it less favorably than developing with Next.js. Is Blazor a good choice? I'm planning to create a blog, so exposure is important.

Finding element in a channel

Hello, I'm trying to implement a queue service for one particular type of long running task. It's added to queue by one service that also passes parameters to the task. Before adding a new task I would like to make sure that there isn't a already one with the same parameters. This is my first time working with queued services and I a bit confused if I'm even using it correctly.

✅ Basic

If someone knows c# basic dm me private so that I can ask questions if I may not know something while I do a exercise (Im a beginner student)

C# socket server

Hi, I'm a C dev relatively new/intermediate to C#. Currently working on a socket server C# library to improve my knowledge in this language and have some fun competing on TechEmpower benchmarks. Would be great if anyone could look it up and give some improvement feedback, or just feedback. This project can only run in linux systems (sorry windows) as it's epoll based. I can provide a docker image if you need to test or run locally....

✅ Login & Register in asp.net

A month ago I created a basic register & logic classes + pages for my future project. I'm not sure what I did, but maybe I've got a guide here and with AI of how creating it, and I was told to create them with records instead of classes (I don't remember why). Should I create with records similar to this? ```cs...

All reference is yellow triangle

Hello, i'm new to C#, when i'm loading the project, all my reference cannot be loaded, Even tho in ../packages/... i have all the library, other PC i can load the project normally but this PC cannot, how to fix it?
No description