C#

C

C#

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

Join

✅ Why won't the loop loop?

```cs public class Game { public Task gameloop = Task.Factory.StartNew(() => {...

How to get value in big TagCompound

I`m making minecraft schematic analyzer in c#, and i need to get BlockList and BlockPalette from entity. It looks like this: ``` entity: (Compound) CanUpdate: 1...

Question about Avalonia structure, addon capability and generall seperation of projects

I want to make a small Desktop app using Avalonia, my current structure is: MyApp.sln contains: - MyApp.UI -> for UI stuff only - MyApp.Core -> for logic...

Unable to (somewhat) gracefully terminate some processes

Hey! Newbie here with very limited skills trying to learn. For context: I currently have a batch script that uses the command-line tool TASKKILL to end a bunch if processes when needed. I'm looking to implement this in my current C# app in a somewhat more "proper" way. I've been testing this by running PowerToys minimized and trying to end that process as gracefully as possible. The TASKKILL command seems to be able to end PowerToys without the use of the /F (force kill process) parameter....

✅ Brand new to C# and Unity

For some reason my else statement isnt attaching to the previous if. Im wondering if i missed something or not. I recently set up sprinting right before it, and heard you can only put one update per class, so i have to cram all my movement updates into this one area, and it looks just like a bunch of if else statements spammed everywhere.
No description

✅ How to test for memory corruption in your implementation

So I have a method Foo that does some SIMD and pointer shenanigans. Now I want to write tests for it. One thing I'd like to test is out of bounds accesses of the data I process. My thought was that I setup three contiguous pages [A B C] and apply a page guard to A and C while the entirety of B contains the test data. The idea is Foo going out of bounds is not a critical error in this test, it should simply fail the test. The problem is: in order to use page guards I have to make the page read only. However, making the page read only triggers an AccessViolationException in C# when I write to it and the process is shut down. Since [HandleProcessCorruptedStateExceptions] is no longer supported I cannot prevent the entire process from shutting down. Any idea on how I can test for out of bounds accesses without killing the entire process?...

WPF horizontal scrollbar is slow and doesn't move to click

I'm making a custom control which has a scrollviewer that can display "long" data horizontally. Think something like a video editor, or a timeline type control. I noticed two issues: 1. If the scroll area is large, I can't click/hold/drag the thumb very far. I have to keep doing it over and over and move it a little bit each time. 2. I can't click on the space between the thumb and and another part of the scrollbar to move the thumb to where the cursor is. ```xaml...

Sidebar Hover, Display Sub Items (Blazor / .css)

About the project Hey there, ive been making a versitile tool for sidebar for some work related stuff. currently its an advance resuseable sidebar with infinite nesting, and it supports eventcallback on click of an sidebarelement The issue...
No description

✅ Question about front-end frameworks

In college we mostly built front-end with vanilla JavaScript or a bit of jQuery. I want to learn a modern front-end framework that: 1.uses TypeScript (I want to learn it as well), and 2.has many ready-to-use components out of the box....

✅ C# Winfrom Chart

Is the animation feature built-in or do I have to create it myself?

Need help with MVVM

Hi guys, i need to make a NotePad, i choose to make it with Avalonia, i want to use MVVM, but i don't understand it, can someone help?

Help with Whisper.net (AI Voice detection)

I'am trying to make a substitle generator using whisper and ffmpeg. But i noticed that when nobody is talking (in the video), the subtitle shows too early... Is there a way using Whisper or anything else to fix this? Thanks. Watch the video to understand well, even if its not in english : https://streamable.com/tkzeah

400 bad request on seemingly valid POST

I'm guessing this is a really stupid thing I missed or something like that, but I'm not sure what exactly it is. I have this post handler: ```cs // added with app.MapPost("/usernew", UserPost); public static void UserPost (string email, string userName, string password)...

✅ What is happening with my VS?

See the video... When I type semicolon in razor file, VS automatically put multiple blank lines somehwere in the code block, why?

✅ MenuItem outline WPF

I cant remove the default outlines on the MenuItem. I've tried lots of stuff and can't figure it out ```c# <Style TargetType="MenuItem"> <Setter Property="Background" Value="#2C2C2C"/>...
No description

✅ This label has not been referenced error by "defualt:"

this code sample about switch case ```cs using System; ...

How to work on someone else code to implement a new feature

Hello, quick question, I'm currently doing an internship. Last year also I did an internship where I needed to build something, it was pretty interesting. But this year, what happens is that I was put directly in a team to work on leftover works in their backlog (very boring tasks). Even though it was boring, what I noticed is that the codes have been written by many devs and it rarely happen that we work on something from scratch. So my question is, say I need to understand the code of what developers did, how do I do that? I mean for example, I started to debug things, I understood what's happening on a high level but there are still things that I feel without knowing what was done initially, from scratch, it's a bit to add/implement something. So I wanted some ideas on how you guys do when you need to implement some codes in a software that wasn't written by yourself, it's kind of annoying, right? But I do realise that this is what's going to happen when I will work on full time job, just wanted some advice on how to tackle/exit out of this scenarios....

✅ Unable to create a 'DbContext' of type 'ApplicationDbContext'.

hi 👋 i'm trying to structure my project with DDD model but getting this error: Unable to create a 'DbContext' of type 'ApplicationDbContext'. The exception 'The entity type 'IdentityUserLogin<string>' requires a primary key to be defined. ...

I want to add content to my database's table from API's data I pulled from an external source.

public async Task<Results?> pullGoogleInfo() -> Which pulls Places API data from google Places API. public async Task StoreInDB(Results apiResults) -> Stores the content inside my DB (PostgreSQL). It adds row for each JSON element inside the data of google. Now, I want to create a controller which uses those methods and I apply this controller with swagger. I got this idea from chatGPT (OF COURSE) but I don't understand what he explain much, so I need help please. ...
No description