C#

C

C#

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

Join

How to delete a cross-domain cookie

Hey, I'm working on a web app (next.js as a frontend and .net api as backend). I decided to try cross-domain cookies to make authentication more simple. it works, i can log in or register, but when im trying to clear the cookie on logout the problem comes. i tried to do this on a frontend initially, but then i found out that i could only be done on the "main" domain. Logout endpoint returns "Ok" but i still can see a cookie in browser. here's how i set and delete cookies ```csharp
private readonly CookieOptions _cookieOptions = new() { HttpOnly = true, Secure = true,...

✅ Can you make labels scroll alongside input?

Hey, so I'm rather new to C# in general, we've been learning it in a course to play around with things like OpenGL or Unity eventually, but for now there's the classic programming assignment of making a calculator; I've more or less got the logic of it down.. What i've currently done is that i've made all the buttons add certain characters to the label_display.text property, and i've made some validation that the user does not enter dumb stuff like "9*+-25", then i parse this string and turn it into tokens of values and operators, turn the normally infix expression to postfix and then evaluate that expression and overwrite label_display.text with the result. -- intro ends here...
No description

✅ [SOLVED] Weird DTO response

Hi! I'm working with Dotnet8 and im creating a web app with Vue. I wanted console.log a DTO which looks like this: { "contentType": null, "serializerSettings": null, "statusCode": null,...

✅ Help 2.0

Color accentColor = Properties.Settings.Default.accentColor;
string color = accentColor.ToString();
Color accentColor = Properties.Settings.Default.accentColor;
string color = accentColor.ToString();
...

✅ Help?

So my code here anything with a self-reference it deletes itself. I don't know why. ```csharp private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));...

✅ .NET 9.0 - CSharp WinForms (Closed Case)

In order to get the best help I need I shall provide a little background to my application I have been working on for the past year. Encryption Forge is my application name with many features. Recently I reached to this point where I received an error that is unrelated and I don't understand. This error prevents the application from running and thows a object reference error. However the object reference error is not the main problem. It is something within the InitializeComponents or in the loading of public Main(). I tried to narrow it down but if I remove everything or bits from the Loading of public Main() it works and then if I do the same it doesn't. Im confused so much. Something you may need to know is that I am not a professional. I use hand made code, code snippets and a bit of help from ChatGPT (Not often though). So my code is wack and disorganized if I do say so for myself. I want to hand off the project by files but It's supposed to be a secure software no one can have other than me and my friends. This software can not be seen by others (The public)....

.Net, C#, MAUI Developer

I am looking for .Net and C# Expert. If you are interest, plz let me know....

Java to C#

I wanna help from pro who can tell me how much I need to learn C# if I want to migrate Java backend to .net

✅ How to write unit test for this?

I have controller with this method: ```cs [HttpGet("stream")] public async Task StreamAsync(CancellationToken cancellationToken) {...

✅ Is it worth to use stackalloc here?

Hey, I have this: ```cs [HttpGet("stream")] public async Task StreamHeartbeatAsync(CancellationToken cancellationToken) {...

Control getting resized when adding to FlowLayoutPanel

Hi. I have a weird problem. I have a FLP and I'm adding controls to it. I have four UserControl classes, each is 865 wide. Three of them are fine when I add, but when I add CtrlImage usercontrol it goes to 1298 wide. In trying to nail it down, I've removed all code from the class so it isn't doing anything crazy. It just has a single label and picturebox. I determined when it happens: Control ctrl = col.GetControl(); MessageBox.Show("1: " + ctrl.Width.ToString()); record.Controls.Add(ctrl);...

Safely getting a result from a async method within a sync method

I have an async method that returns a response object. In the calling sync method, what is the best way to get the result and capture any possible exceptions? ```csharp public static Task<ResponseObj> AsyncMethod() {...

Compiling C# as a WASM component

I'm trying to follow the guide here for compiling C# as a WASM component: https://component-model.bytecodealliance.org/language-support/csharp.html When I run dotnet build though, I get this error: ``` Restore complete (0.4s) You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy...

help in active firebase database for my project

i want to set the firebase database setting to connect into my app using the info for activations

✅ Getting duplicates out of a list

Hey, I have a C# code where I have a list of byte arrays (which are extracted from Images of a folder and I don‘t know how many there are - ps. They are too many - the code I wrote the Program in was in Windows forms) and there are duplicates in it, but I don’t know how get the duplicates out of the list dynamically. I couldn’t find a really good solution that does what I want. Thanks for help!

✅ Including documentation of the STL in a custom override

Hey there 👋 We're building a library that acts as a limited superset of the C# Standard Library We'd have a method called FooMathMin that uses Math.Min internally with some post-processing. It should have its own documentation followed by Math.Min's original documentation if possible...

VS Code vs Visual Studio

I'm a beginner to C#, I've been told to learn Net core for a potential job so long as I'm successful but every tutorial and resource I come across uses Visual Studio code instead of visual studio, is there a reason for this? I need to learn using Visual Studio because that's what I'd be using in the job 😦 Also if anyone has any resources that I can learn with which uses Visual Studio then please share! ❤️...

✅ I need help for create a videogame

I'm looking for a developer to create a video game, I already program a bit on my own but I don't have the level to make a game on my own.

Cron job "0 */30 15-16 * * ?" in Quartz .NET runs also at 16:30 p. m. Is this correct?

I would like to have a job that starts at 15:00, executes also 15:30 and 16:00. Is this possible without creating two jobs in Quartz .NET as ChatGPT says? Also our application executes at 15:00, 15:30, 16:00, 16:30. I don't see how 16:30 fits in my cron job above, but I definetly don't want this. Since other jobs are executing just fine and no other customers reported the problem, I don't neccessary blame the cron generator. Chat GPT suggest having 0 */30 15 * * ? and 0 0 16 * * ? ....