C#

C

C#

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

Join

✅ Deserialize JSON back into custom object

Hey all, I have an ObservableCollection that I am using to store a list of tasks (A custom object "TaskItem" that is build like this. ```c#...

✅ ”base”

```cs public class Person { protected string ssn = "444-55-6666";...

✅ Change WPF element style depending on property value

Hey, trying to set the "disabled" color of a button in my little practice app. I have the button setup with a command binding so that unless something is selected in a datagrid, the button is disabled. I tried setting up a style trigger but assuming whatever is handling disabling the button automatically is not setting the "Disabled" property though. ...
No description

How to convert a whole json file to C# classes with Newtonsoft.Json?

Hello, I am curious if there is a way to convert a whole json File with Newtonsoft.Json to C# classes without knowing anything about the file. The code should be written in C#. I tried nearly every tutorial on YouTube and every Tutorial is about serializing or deserializing only one object at a time, and I looked over on some examples on Stack - Overflow and even Bing Chat gives me the same answer. I really need this for a Project I am building on, any example with the specific topic I was writing about earlier could help!
Thanks for help!...

✅ get set help

i dont understand the application of a get set method. are there any practical examples you can give?

VS hangs while typing

Curious if you guys had any ideas My machine at work is running VS When I type in the code editor, it's often several seconds before the editor catches up to what I typed and several seconds again before I get suggestions or the intellisense browser. ...

Does it make sense to two references (to database migration and data seeding) in the same using

I am totally new to this, so I rely on chatGPT a lot With the help of GPT I have wrote a code like this ```var app = builder.Build(); ...

Guessing game

Have several build errors for a guessing game i made in a form app using Guessing_Game; using System; using System.Windows.Forms; ...

OOP guidance (for myself)

I'm having a real tough time grasping OOP for a project in school using Monogame, like I can't quite figure out how to reference variables / sprites and such from other classes, maybe i'm just being silly but I was looking for any in depth OOP guides, tips or even talks from people

Call method with updated data

Hello, im currently trying to make an update function. I got 2 lists: ```cs public class AircraftData //stores the data for the startup...

navbar

i want to create a navbar with an expandable thingy kind of like a treeview i have this html ```html <div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">...

learning C#

having trouble with a simple code asking for name and age and the app should output it but doesnt seem to be working any help is greatly appreciated namespace collectNameAgeApp { public partial class Form1 : Form {...

✅ What's new in .NET 8 regarding making a WASM project?

Hello guys, I am looking into learning Blazor WASM. I was viewing some tutorials online on how to setup the project but everything seems to have changed since .NET 8. ...

Partial classes and platform specific code

Hello. Trying to create platform specific code and only use/compile the code for correct platform upon release. My current issue is that regardless of platform my linux specific code is trying to run on windows. I seen examples of it using MAUI, however i'm just trying to make a simple console app. In my csproj: ``` <PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))"> <DefineConstants>WINDOWS</DefineConstants>...

A problem with blazor while verifying cookies

I created a login system with JWT refresh token. The code works well when logging in and so on, but the problem occurs when the JWT expires. I need to send a refresh token request to get a new JWT. The process succeeds, but the issue is that during the first page refresh, the user is not activated. On the second refresh, they become activated. I don't know the reason, even though I ensured that the operations are not synchronized, so the request must complete before displaying the page after updating the cookies. However, what happens is the opposite, I think. What is the solution?...

Migrating to EF Core migrations

Hello I'm rewriting a whole backend from TS into C# and I'm struggling at the migrations part after I scaffolded the db context. How would I start using the migrations system EF Core has without just nuking all the data?...

✅ Z position controlling of my WPF window

Hello, guys, i'm developing a WPF application for a game, which source code I don't have. I want to make a window, that always will be on top of the game window, but if there is a some other window, for example browser, it can be on top of my application. I have one idea to use C++ functions for windows from user32.dll, but it looks complicated and I think there is a simpler solution. Is it?