C#

C

C#

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

Join

✅ How to move an NPC locally only

Im just trying to make an npc move to a location only for the client player only. My code below doesnt work ```lua print("running") local NPC = PlayerNPCFolder:WaitForChild("Noob") local humanoid = NPC:WaitForChild("Humanoid")...

✅ Taking user input using Console.ReadLine()

Hello guys, can someone explain why my IDE (rider) has underlined the Console.ReadLine method pls. ```C# Console.WriteLine("What is your name?"); string name = Console.ReadLine();...
No description

Defining a protected method with a single call. Failing verification and I can't figure out why

Hey all, I'm making my way through a beginner tutorial at dotnetacademy and I'm at the final exam for the beginner level. I'm getting an error when I try to verify my submission centered around my definition of the PrintQuestion method and I can't figure out what I'm doing wrong. The error I'm getting back when I try to verify my answer reads:
*Not all requirements have been met....

✅ Run the program as administrator without unnecessary windows

If my application is immediately launched with administrator rights, how can I make a function that will call an .exe program that requires administrator rights along with redirect without unnecessary windows?

Seeking Advice ( m new to dev )

( i dont have any knowledge in front end ) I have implemented my first API (a to-do list API) and pushed it to GitHub. In this project, I covered the following topics: Repository Manager and Base Repository for the Article entity. Service Manager and Service for the Article entity....

Casting and Convert method in C#

Hello guys, sorry to disturb you all; I just have a little question. Consider the following: ```C# int num1 = 20; num1 = (double) 20.0;...

✅ Error when uploading package to microsoft store

I get this error when trying to upload my .msix file

why is my code weird??

Hello, i'm really new to game dev so i'll make it quick, i'm startting to learn with this videos of Pandemonium and i'm getting to the code part, i'm using Visual studio for the code but i think i missed something, i couldn't find why avent after double checked...
No description

Implementing OpenIddict in Blazor Hybrid

Hello there 👋 I'm developping an app and I am looking for some advices! The solution is currently architectured like this: - ASP.NET Core app...

DI Service Usage in Quartz.NET registration

I am using Quartz.NET as my scheduling framework, because Quartz.NET has a built-in support for persistent storage, which solves many problems for me out of the box. The problem is the configuration of the connection string for the database. I got a scoped service which resolves the database connection string, since the appsettings.json only includes the template connection string. The actual user and password comes from a vault during startup. Therefore I have to use the service. As far as I know, Quartz.NET has no overload to utilize the IServiceProvider. Because of that I created this overload method ```csharp public static IServiceCollection AddQuartz( this IServiceCollection services,...

Help Integrating email service in .NET

Hello everybody I need some help in integrating emails sending service into my .net ASP API I’m new to this and I don’t know how to implement this and what is best email service? And can I do this implementation for free or not?...

Maui.Graphics, using a razor file instead of a .xaml.cs file

Im using the maui blazor hybrid, and for the project im doing it would be better to use a razor file for it then .xaml.cs file. I cannot figure out how or if it can be done. it sounds like its supposed to work. I need help figuring out the syntax for it. Thanks anyway. (I know the code doesnt do much) but just if i can somehow do it type it directly into the beam.razor
No description

Add NuGet package to shared library not possible (Rider)

In general, it should be possible to install NuGet packages in a shared library, right? 🥴 I have a weird sln. I have 2 projects in my solution, 1 App project that depends on 1 Shared Library project. I can only install NuGet packages in the App project, and for some reason the namespaces become available in the Shared Project then as well. If I try to add the NuGet package to the Shared Project, Rider simply opens a dialog to confirm and then does nothing. ...
No description

User ID on Client Side or Not?

Hi, I’m building a Feed application, somewhat like Facebook. So far, I’ve implemented it in a way that avoids fetching or using user IDs on the client side. For example, when fetching posts or liking/commenting on one, I send a request to the server with just the post ID. On the server side, I handle the like or comment by finding the post using its ID, which is tied to a user ID, and update it as needed. This way, I don’t need to use the user ID on the client side. Similarly, when fetching data for myself as an authenticated user, I get my user ID directly from my identity on the server, so there’s no need to pass my user ID explicitly. However, if I want to implement a profile page, I’ll need to locate and display a specific user’s profile. For this, I assume I’ll need the user ID available on the client side. Would this approach be fine?...

Dockerizing dotnet

Can anyone help me with dockerizing .NET backend? I have used Golang for backend before and dockerizing that was very simple, but it seems very complicated in .NET....

Copy paste detector

Hi, I‘m searching for a good copy paste code detector for my ci pipeline. I tried sonarqube but I want to have the result in the ci and don’t want to wait for the webhook. pmd cpd looks quite promising. What are you using or recommending?...

✅ uploading to microsoft store

trying to publish my app need help packaging it

Windows Forms

When I create a simple button, and put a text align, whenever I click on it it moves a little to the side. How can I remove this? .NET 8, Windows Forms, Windows 10...

edited data/user input not saved in db

I have a card view as per screenshot attached Right now my edit button fires up the edit view onclick, but once the save button is clicked the edited data is nowhere to be displayed. I have checked if my db saved it (it did not) ```+----+---------------------+ | Id | ListingName | +----+---------------------+...
No description

{} vs [] when initializing an array in C#

Hello guys, is there a difference when we use {} to initialize an array or if we use [] ? I read that the [] is known as a collection expression. ```C# string[] orders = {"B123", "C234", "A345", "C15", "B177", "G3003", "C235", "B179"};...