C#

C

C#

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

Join

What should I do next?

I’ve grasped some basics of C# and now I’m capable of creating simple console applications with API integrations. Should I continue learning basics? (If yes, what should I learn) or could I dive into ASP.NET? What would be better for my learning?

Null Warnings

I am making a class with 3 overloaded constructor, but I cannot bring myself to put the same code in 3 constructors, so I did it like this:```cs public enum InsertMode { Append = 0, Truncate = 1,...

Good Apps to Help With Studying for Mobile Users?

Hello, I am as newbie as newbie gets, I am making my first attempts at code using C#, are there any good apps I could use on my phone while I am away from my computer? Thanks for your help!

✅ Do I always need to avoid coupling?

For example, I have a class Application where the main part of my project's logic is written, and I also have a GenerateVocabulary object which will itself use an Interface to actually generate content. Will it be good practice to simply create this object inside my Application class? And in general, is it acceptable in a professional context to create one object inside another if I'm 100% sure that I won't change it?

I have a problem with the reloading of the text editor.

So i made a text editor for basic scripting programs and when i use the script pane it has this weird reload and blue highlight it affects the scrollbar and it should only update one part not the whole script

Best way to deserialize duplicate JSON API responses (Using Newtonsoft.JSON)

I'm using a HTTP client to contact an API, and then deserializing the JSON response into an instance of its respective object type. My issue is this - the API has two versions: - Version 1: The old API, but still active, however, it's not maintained and may be missing bits of data that are present in requests made to v2 of the API. - Version 2: The new API. Almost identical responses to v1, but all of the fields are obfuscated....

The Given key was not present in the dictionary

ive revived a nostalgic old mobile game and ive converted the offline dead servers from smart fox to photon and everything seems to work but one mode in the game doesnt work at all here is a code snippet public void BirthPlayer(PhotonPlayer player) { if (!SFS_Player_Arr.ContainsKey(player)) { Multiplayer multiplayer = new Multiplayer(player.ID);...

how to avoid "-0" when converting float to string?

when I convert floats to string like in this example, often I get "-0" as a value. Does anyone know a simple way to convert these to positive zero? ```csharp public static string _Serialize(this Vector3 value) { return $"{value.X}, {value.Y}, {value.Z}";...

Extra bytes in TCP message

Sent some message to a local tcp server, and it sent some extra bytes along with the message. What are these?
No description

Why is my JWT token not getting authorized and not getting entering the [Authorize] method?

```C# [HttpPost] public IActionResult Login(LogInAndSignUp user) { var logUser = context.LogInAndSignUps.Where(x => x.Email == user.Email && x.Password == user.Password).FirstOrDefault();...

Any case where `TError` can't be boxed in example?

So I have the following: ```cs public class ParseResult<TResult, TError> { private readonly TResult? _result;...

When to use Dependency injection?

I am learning WPF and since I am used to work with DI almost always in my previous projects (mostly APIs) I am not sure if I need it. Is using DI in wpf really best practice? My app is currently not really complicated, I only have some kind of Get data from API and save to db. Is DI recommended in this case? or does wpf have any special "best practices" what should you work with?...

System.Data.SQLite cannot install

Hello, I am trying to get a connection with my database in VS Code. I tried installing NuGet Package Manger and System.Data.SQLite but it keeps giving me this error message. Can anyone help me install it correctly or tell me why it isnt installing? Thanks!...
No description

How in ASP.NET Web API application .NET 8, Set server time in UTC?

I have an Web API application, I would like to operate with utc timezone in application

WPF Scaling Bug

I currently have a problem with the scaling of my WPF application, unfortunately I can't give too much code or information for internal reasons. The problem occurs when I set the scaling e.g. from 150% to 100% or to 300%. The LayoutGroup boxes and items move as you can see in the picture About the project:...
No description

Having issues setting up Avalonia

Im trying to make a game engine with C# (as a hobby) so to start and since I'm using Linux with VSCode, I chose Avalonia. After installing the packages, the function StartWithClassDesktopLifeTimes is not working because 'AppBuilder' does not contain a definition for 'StartWithClassDesktopLifeTimes' and no accessible. I don't what I did wrong or what extension I am missing....
No description

Border.Background property

I want to use the property Border.Background, but it tells me that this attachable property was not found in type 'Border'. How can I fix it, do I have some missing libraries or something ?...

✅ Catching keyboards from Remote Desktop Session

Hello I've tried to catch keyboard events from Remote Desktop Session opened. It worked when window mode, but when I make it full-screen, key catching didn't work. How to solve this problem? Regards....

✅ My program can’t be run.

I got a problem when I run my program. .NET SDK version: 8.0.403 Mac OS X OS version: 14.5...
No description

WPF TreeView Fails to load ItemsSource

The control ``` <UserControl x:Class="XMLViewer.Features.XMLViewer.XmlViewerComponent" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"...