C#

C

C#

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

Join

Change the struct size based on current architecture

Hi, I'm working on porting a C library to C# that contains architecture-dependent structs. Here's my C code: ``` typedef struct windowManager_t { char *name; void *window;...

βœ… enable single-click cell editing in Avalonia DataGrid

Hi all, In my Avalonia UI DataGrid, clicking on any cell currently selects the entire row, and I have to click the cell one more time before I can start typing. I'd like to achieve:...

βœ… What in the hell am I being asked to do here? Whats being done by me doing this?

Hey everyone, I know this isnt exactly coding but I cant possibly begin to think where else to try and find an answer to this so I defaulted to here. Im using CodeAcademy to try and learn C#, and literally the 3rd thing it asks me to do I dont even know what It wasnts from me. What the hell is a CS and why am I typing it? What does it do and do I even have it? Im so bafflingly confused as to whats going on....

DbConcurrencyException, what am I missing?

Hi, getting this on the SaveChangesAsync and im not really sure what im doing wrong. DbConcurrencyException: The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. ...

βœ… When targeting multiple frameworks, which one runs when pressing Ctrl + F5 in VS Code?

Anyone knows which app runs when pressing Ctrl + F5 (Running without debugging) when targeting multiple frameworks in a console project? I have attached pic of project file, launch config file and build process which starts after pressing Ctrl + F5 in VS Code. I have both <TargetFrameworks>net9.0;net8.0</TargetFrameworks> in project file....
No description

Create MSBuild custom task to modify C# files before compilation

Hi, I need to rewrite some properties and function calls for interop, and would love to do that in a MSBuild Task. How can I overwrite the Compile item group with my modified files?...

Coursework analysis of quicksort results in (very) unexpected behaviour

Desc: Implemented simple recursive quicksort algorithm to test it on a 'A' shaped arrays of different sizes (eg. [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]). Expected behaviour: (BASED ON MY THOUGHTS) - rightmost pivot: O(n^2) - at least for 'A' shaped arrays...

Jwt

Hello everyone, I'm new to C#. I've created a web API. I'd like to implement JWT tokens without Entity Framework. Do you have a tutorial you can suggest? Thanks for your reply.

MAUI CarouselView Lag Issue.

Maui CarouselView smooth when start scrolling, after few scroll CarouselView starts lagging.

Fancy Button color change.

Hi all, I am trying to change the color of a button background. It is initially set via a custom control using the <setter> tag as a template like so: ```...
No description

are there any good, up-to-date books on entity framework core?

i've been reading "Entity Framework Core in Action: Second Edition", but I'm not really liking the way it's structured. I've taken a look at "Programming Entity Framework: DbContext" as well, but it was published 2012 and only seems to cover working with DbContext stuff (which is useful, but I need a more comprehensive intro to ECF). I've got a subscription to o'reilly learning so I'm looking to maximize its use. can anyone recommend a good book suited for newcomers to ECF (and maybe .net in general)...

How do I get webpack to integrate with cshtml files?

I have an ASP.NET Framework 4.8 MVC project that has cshtml files. I currently do bundling via BundleConfig.js. I need to migrate to something else because we are migrating to ASP.NET [Core] and that functionality doesn't exist there. Microsoft recommends switching to something like WebPack. I am switching to webpack now before migrating to .NET so that the amount of churn necessary for the .NET upgrade is minimized. However, I'm finding it hard to see examples of how this integrates with .cshtml files. Currently, my bundles are generated with a hash to break the cache when we deploy....

βœ… why am i getting the CS0246 error on unity for this code?

please help! im new to coding and i cannot figure this out
No description

βœ… Which API to use to manage wifi networks in console app. Currently trying ManagedNativeWifi.

Hey I was trying to scan for wifi networks and connect, disconnect to them from console app. I am currently trying out ManagedNativeWifi. The only issue is it does not provide any way to create wifi profile from scratch. So it would be awesome if there is an API which does that or I have to make my own implementation....

AngleSharp doesn't send request on SubmitForm

I'm trying to automate some tasks at uni. At this point, I'm trying to reset the times of lessons to the correct value in the online registry. I figured I'd use something more serious than manually doing http requests, ended up implementing it in AngleSharp. The issue I'm facing is that SubmitAsync runs, but doesn't actually send any requests. It's supposed to send a Post request. https://github.com/AntonC9018/ScheduleLib/blob/163a747b62e87ff24ba3cada39d73277e75bd473/src/OnlineRegistry/OnlineRegistry/PublicApi.cs#L313 ...

βœ… Need Help with .NET C# Console Project (visualizing) (SOLVED)

As you can see in the Image, I get following result, on first option and second I get normal result I want, but on third and so on as you can see that Background Color is even on next line and I don't really know why... I have my own Qprint Method in my dll ```C# public void Qprint(string msg, string TextColor, string BackgroundColor) {...
No description

βœ… Newtonsoft.Json JsonSerializationException

As the title says, I keep getting a JsonSerializationException. I have no idea how to view the Exception details so if anyone could tell me that'd be nice. I've followed a few tutorials on this topic, but absolutely none have worked. Two exceptions occur in System.Private.CoreLib.dll and one in Newstonesoft.Json.dll ```private async Task LoadData() { var clientJson = System.IO.File.ReadAllText(clientDataPath);...

βœ… Hosting ASP.NET Core with MSSQL on a Linux VPS

Hello, I have a question regarding ASP.NET Core deployment on a Linux VPS. Is it possible to host an ASP.NET Core web application together with MSSQL on a Linux VPS without major issues? Is Docker the only viable solution for this setup? ...

βœ… System.IO.IOException Being Thrown

As stated above, a System.IO.IOException is being thrown. I believe it's being thrown because the Streamwriter is trying to write to a file that "doesn't exist", but I am creating the file before that code runs. Any ideas on what could be a solution? Thanks! ``` private async Task SaveMessages(bool ForceSave = false) { Spark.DebugLog(ChatMessages.Count.ToString()); if (LogMessages || ForceSave && ChatMessages.Count >= 0)...

βœ… ASP.NET Core Web API Model Creation.

I have complete the restfull api know i want to know how can i create Foreign key, on cascade delete, set varchar(100) and many more