C#

C

C#

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

Join

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

✅ Binding Nested values in RequestBody to Model

Consider the following model I use inside the MVC structure: ```cs public class Collection { /// <summary>...

job advice

ok so i just passed some offline technical tests for a asp.net backend dev job. but honestly, while i'm quite experienced with C# as a WPF dev i dont know much about asp.net and havent really developed anything using it. i might have an interview in a week again, so can you prime me on what i should learn in this week? as fast as possible, i want to get as much knowledge.

csc.exe takes 140 Seconds to build one specific Project

this here is from dotnet build -bl ``` 18> 17 ms CallTarget 3 calls 18> 17 ms CheckForDuplicateItems 3 calls...

✅ Changing ASPNETCORE_ENVIRONMENT causes broken site.

Hi all, I am wanting to test our ASP .NET CORE App coupled with Blazor Wasm in production. So I changed ASPNETCORE_ENVIRONMENT to "Production", and altered Program.cs to work with it:...

Need advice on how to update my WPF app from .net6 to .net8 with minimal disruption to users

Hello. I tend to work more in asp.net, but a couple of years ago I was asked to build a WPF application that is distributed to ~1500 users. I chose .net6 at the time as it was the latest LTS. Because of a lot of weird customizations that were required, I also built my own updating framework for it. For two years this has been fine, but now I'm being asked to upgrade it to .net8 LTS. This presents some challenges. My application is 12MB because the installer would install .net6 desktop runtime (I'm using Advanced Installer). It's a single file application. I now need to figure out the best way to update this for all users to .net8. I am able to push out updates to my application just fine, but I don't have a good sense for how I can upgrade to .net8. My first thought was to include it in the app, but now my size went from 12MB to something like ~184MB. This is difficult because every update would now require the full .net version, presumably. I looked into trimming but I guess that isn't supported for WPF, of course....

Inheritance

Hello all, I have an inheritance problem. When I create an object Entity x; and later I asign him the value x = new MovingEntity(Texture,Position), the values are not assigned onto x. Why? class Entity...

Open brace on new line for new Control Blocks not working

Hi everyone, it seems that since the last update this function isn't working for me anymore? For example, when I write an if statement then write an open bracket and press enter it doesn't put the open bracket into a new line anymore. Is it the same for anyone else and does anyone have a solution for that?...
No description

✅ Does .NET 8 compiled by .NET 9 sdk as production ready as .NET 8 compiled by .NET 8 sdk?

.net 9 sdk can target .net 8 Where do I get more info on this topic?...

Publish A Project That Reference To Another Project To Output DLL To `libs` Dir

Hello, I have a project X that compiles as library (DLL) with has a lot of nuget packages. This project used as utils for my other project, project A. Project A is a winExe project, self contained that I want to publish. Upon publish, it builds project X than project A....

Get another writeline on second itteration

Im storing a username and password (fejk ones) in an array and using this for-loop i want the second pass to display "Pick a password", how do i go about this? string[] user = new string[2]; for (int i = 0; i < user.Length; i++) {...

✅ .NET 8 enum to string serialization throws an exception

Hello, Following the docs, a custom JsonSerializerContext is applied on the controllers, yet an exception is thrown. ```c# public sealed record GetLinkMetricsRequest...

What is wrong with my C# Perlin noise generator?

I've been trying to code my own implementation of the Perlin noise algorithm based on this paper: https://www.cs.umd.edu/class/spring2018/cmsc425/Lects/lect13-2d-perlin.pdf However, it ends up producing a weird pattern which is pretty far off the result I was looking for. The image it creates is below. I tried messing around with the noise function and dot product function, but I'm unsure of what is actually going wrong. I suspect that I've made a silly error with the logic behind it, so if one of you could point that out for me then that would be greatly appreciated....

chinese checkers Unity 2d

hallo i am new in this server and i want some help if anyone interested. my name is dani from sweden and i study game development in the university. we are working on a project to make a chinese checkers in unity and i find it hard to understand the MVC pattern we are working with. if anyone can help me understanding the cod better i have the project and all the scripts. pls send me a message.
No description

✅ How do Avro, ORC and Parquet work?

I have been learning about big data and these came across as a few of the popular "optimized file formats". I want to understand how they work.

Rectangle Collision Detection in Monogame

Hello, I am working on a game for my A level Computer Science course in Monogame. I am trying to work on rectangle collisions (I previously tried per-pixel but ultimately decided it wasn't worth the trouble). I need something to happen when two rectangles (one always being the player) collide, and given the types that collide, something different will happen. For enemies, there will be a check to see if the player is attacking, if they are, the enemy will die, and if not, the player will take da...
No description

Database adding letters to my output why?

public User GetUserByUsername(string username) { var usr = _context.Users.SingleOrDefault(x => x.Username == username); Debug.WriteLine(usr.PasswordHash); return usr; }...
No description

Diagonal Inputs not reading at all

I'm making a fighting game in Unity and I'm working on the input buffer for it. With this I can dynamically create new special moves and perform them Everything's working correctly so far except diagonals inputs don't read at all. I added a debug log to check whether it is actually being processed an no nothing's happening at all. Here's the script: https://pastecode.io/s/5q7mu5ax HandleInput() is working correctly but HandleDiagonalInput() isn't working at all...

ASP.NET WEB FORMS

I have a project to do in asp.ne web forms , right now its running on my local host but it needs to be a publicly accessible url so im unable to send emails to other devices unless they send me the url and then i ahve to open it on my pc
No description