C#

C

C#

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

Join

code explaination

hi im new and i would really like someone more advanced to explain what this code does and also answer up my following up questions, thanks :D

.Net Aspire

wanted to know if my client is Unreal engine and i want to link it to my .net Aspire project with microservicees just want to know which ip should i give my unreal project to be able to talk to my backend i just want to use 1 ip or hostname. i'm guessing we don't connect to the apphost or do we or do i need to create a api to give to unreal like i know how to create deploy aspire but no tutorial showing a nother client connect to aspire....

Trying to log information about event being used

Hello, i am a beginner in C# and i just want to know, how can i log info about an event in-game (CS2)? I have tried to use this https://docs.cssharp.dev/api/CounterStrikeSharp.API.Core.EventPlayerJump.html but when i copy and paste in into my code it doesnt work. I did a basic w3schools exercise on C# and some calculation tasks, so i really dont know much more about anything else in C# :D

i have 44 errors that I don't know how to fix

I seriously don't know what I'm doing wrong my program only has 106 lines

migrate to .NET 9

Do we have a guidelines or steps to migrate a solution to .NET 9 from older versions example .NET 8?

Class separation

I've got a console app that does a lot of heavy lifting. Let's say it's got a service class (that performs http calls) as a dependency and the main class is calling it a multitude of times. The unit testing for the main class of the console app is becoming huge. Is it a good approach to just create a class that aggregates all the calls to the service class?

In App Billing purchased fetching on mac os causes restore failed issue sometimes

I am trying to use the InAppBilling plugin library by james montemagno (https://github.com/jamesmontemagno/InAppBillingPlugin) in an avalonia program. I have setup subscription and well configured the settings, info.plist and entitlements for this purpose. But the problem is, the library, when fetching from app store, it sometimes work and sometimes says failed due to restore issue, which I think means that it was not able to connect to app store and fetch purchases.. I saw a solution saying that we just have to keep trying in a loop, but still the error is not clearing. It particularly happens when I am trying to fetch purchased subscriptions list to check if the user has purchased our product or not. Has anyone ever faced this and found solution for it? Looking forward for any help. Thank you!...

Windows Forms drawing not saving

When im drawing on the picturebox (pageImage) and im saving, the data is not saved
No description

Declaring a struct as a constant

None of these methods work, how would I go about it?
No description

✅ How is JsonConverter(typeof(JsonStringEnumConverter<MyEnum>)) evaluated?

Hello, This makes it possible that enum is serialized to string when the request comes in. Is this evaluated on each request, or only once at compile time?...

NuGetCommand@2 restore always picks some old .NET SDK version on custom agent

I have a solution with projects of both old and new .net. When I try to restore the solution as a whole i always get some error like this
##[error]The nuget command failed with exit code(1) and error(c:\w\_tool\dotnet\sdk\6.0.428\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 8.0. [c:\w\21\s\Webjobs\<proj_name>\<proj_name>.csproj]
##[error]The nuget command failed with exit code(1) and error(c:\w\_tool\dotnet\sdk\6.0.428\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 8.0. [c:\w\21\s\Webjobs\<proj_name>\<proj_name>.csproj]
...

✅ Why ins't this EF Core query being evaluated client-side?

Currently, I have this query: ```C# var board = Database.KanbanBoards .Where(k => k.OwnerUserId == AuthUser.OwningId && k.Id == boardId)...

✅ how do i install c# on my pc?

i am trying to learn c# but idk how to install it

✅ ASP.NET CORE Web Application

I am using ASP.NET CORE in my web application and when I am trying to upload a file to an input field even if I don't upload a file and just click the upload button my iis express server just crashes does anyone have any idea? ``` <div class="row"> <div class="col-md-4">...

Issue with code execution

static public int GetMain() { try { Console.Write("Choose A project Type 1-Backend 2-fronted 3-fullstack:");...

✅ Asp .NET Core production settings.json question.

Hi all, As you know you have an appsettings.json file. Which contains some general things such as:...

✅ Visual Studio SSMS error An item with with the same key has already been added

So I am following a tutorial of Model First Approach in ASP.NET MVC in which I am using ADO.NET Entity Model Data, Empty EF Designer model and when generating the database after defining it's properties getting an error of An Item with the same key has already been added. Here's my Model and the error while generating DDL is An item with the same key name is already added....
No description

CanExecuteChanged event

Hey. I am learning how to use Commands in C# and created simple command, to interact with my ViewModel (some notebook manager). If some notebook is selected, adding new note should be possible, if nothing is selected, the button binded with that command should be disabled. I have following code: ```c# using System.Windows.Input; using EvernoteClone.Model;...

Setting wcf response element name

Hi, I'm writing a wcf soap service and I need to align response element name (see file for more). How can I do it?...

How to to dynamically provide T type of a generic method

I am having an interface declaration which has many-many implementations. The usecase/logic is similar, but the return type differs. (tldr: the services parse and validate data extracted from different systems. They each return the parsed structure relevant to the given system and the detected errors). I want to achieve something like this, however I cannot pass the Type retrieved from the specific implementation in the method call. The services are provided through factory pattern. ...
No description