C#

C

C#

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

Join

Need pointers on code for console app.

I've been using c# inside of game engines for a while now, and I've just written some code for a simple console app for the first time for practice. Code: https://paste.myst.rs/4j1fa1ss I'm unsure about how good/bad this code is, the lack of an 'update loop' found in a typical game engine is throwing me off. My main concern is about the while loops when waiting for the player to make a valid input, is this standard practice? ...

Does anyone know how to flip textures in Silk.NET OpenGL?

I am very new to Silk.NET and OpenGL, does anyone know how to flip textures? I've tried making the texture Y parameters 0.0 and -1.0 but neither work. Sorry if it is an obvious answer but I really dont know.

Anomaly with JsonSerializer

Hi there, I was trying serialize my game state class, but when I was deserializing it I got this anomaly error. I double checked my constructor and everything should be well, I don't understand what is the reason for the error
No description

Web API DAL entities (OnModelCreating)

hello, I need help with object modeling using my created ERD

Where is the letter of the array saved?

Hello everyone, Just a quick question. I understand this code based upon the comments but I am wondering why ans just being incremented has anything to do with the logic in comparing where index i is in the string? ```public class Program {...

C# Basic animation, cant get a circle to align between two lines

I have the following code which aims to animate two basic pistons connected to one crank but genuinely dont understand why the pistons arent on the same crank, the second animates in the correct circle motion just not onto the crank, the code is just the draw code not the full timing stuff if you want that i can add it too. https://paste.mod.gg/capoiiuwymsk/0 i know the code is messy and some subroutines need to be introduced etc i just need to get this working before i clean it up and move into a much larger project...
No description

How do i sync 2 Textbox Scrolling Positions i want to make a number counter:

private void StartParallelLoop() { Task.Run(() => { while (true)...

lib for asp.net core dependency issues

Hey I want to move out and generalize certain api configurations, middlewares, etc. One of these would be json options: ```csharp builder.Services.AddControllers() .AddJsonOptions(options =>...

Constants for WPF

atm I'm using static resources in the 'main' xaml page e.g: ```<Window.Resources> <SolidColorBrush x:Key="colour_1" Color="#FE1E3C"/> <SolidColorBrush x:Key="colour_2" Color="#fffcf9"/> <SolidColorBrush x:Key="colour_3" Color="#426A5A"/>...

Saving Draggable objects location wpf

I have like 10 different objects which can be draggable across canvas (textboxes, labels, WrapPanels, DockPanels, etc). I would like to save their location so it will be shown after the restart. What would be the best way to achieve that? Obviously i could do like 3 bindable properties for each object (vlaue, positionX, positionY), but that would be 30 properties which would be really messy and like 150 lines of code (with mvvvm binding). Any idea?...

Problem with the dotnet installation in gitlab-ci (Docker, Debian11)

im using the official dotnet-install.sh script in the install stage https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script this is my current .gitlab-ci.yml: ...

How to find and update a record in a recursive model?

I have the following classes: ```public sealed record NodeItem { public string Name { get; set; } = string.Empty; public string Value { get; set; } = string.Empty; public List<NodeAttribute> Attributes { get; set; } = []; public List<NodeItem> Children { get; set; } = [];...

Is there a faster way of splitting strings?

I feel like I've hit a local minimum with my code. Basically it splits strings on certain characters and lowercases the result, eg. "This fair child of mine\nShall sum my count, and make my old excuse" into [this, fair, child, of, mine, shall, sum, my, count, and, make, my, old, excuse] ...

How do i sync 2 Textbox Scrolling Positions i want to make a number counter:

private void StartParallelLoop() { Task.Run(() => { while (true)...

✅ difference between `MyClass obj2 = obj1;` and `MyClass obj2 = new MyClass(obj1);`

I am learning copy constructors and trying to know how to create shallow and deep copy constructors.

I cannot understand the command pattern.

I was studying patterns and no matter how much I try I can't comprehend this one. Been days of researching and something just doesn't make much sense about it. I will try to give the definition of it that I know of, and all of my questions about it. If anything in the definition itself is wrong, please let me know too!
The command pattern separates the command of a method in it's own object, and is used to solve a few scenarios on your code, which includes making an undo/redo function of the commands or just storing those commands in general, or delaying those methods on the code....

How to make bindings for a native library using ClangSharp?

For context, this is the library that I'm trying to make bindings for: https://github.com/paullouisageneau/libjuice/tree/master (and i'd ideally love to add this to nuget as a package or something)...

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!