C#

C

C#

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

Join

✅ Error handling in C#

Hello guys, consider the following code: ```C# using System; ...

OOP - Properties and Fields

Hello guys, sorry to disturb you all, consider the following code: ```C# namespace Classes; ...

How Todo Email in C# Web API

I made this https://github.com/UmbrellaCrow612/PoliceCaseManagement/tree/master/src/infra/Email.Service and it does send emails if I use my Gmail app password and stuff but I wanted to know is this how companies do it as well and how can I scale it up etc ?

Resource to practice C#

Hello guys, sorry to disturb you all; my university will shortly organise a competition in C# where we would have to solve a series of challenges. I just started to learn C#. I'm not new to programming (I'm still a beginner though) but I'm a beginner to C#. Does anyone knows any website where I can practice pls, from basic questions to data structure etc pls...
No description

Inline if statement best practices in C#

When do we need to use inline statement in C# for best practices pls. For example, consider the if statement below with the condition of the if statement being writen on the same line. Why can we just write the break statement and omitting the curly braces pls. When is that considered a good practice? Say we have multiple if elseif statement, if one of the if else-if statement isn't an "inline" syntax, then every if statement shouldn't be inline ? ```C# for (int i = 0; i < 10; i++) { Console.WriteLine(i);...

✅ Issues with canvas

Hey guys, i'm having an issue with canvas placement: i did this peace of code: ```cs private void GenerateWorld() {...
No description

Cryptography (easy) challenge

Hello, I have to do a simple cryptography challenge for school. You'll find the file and the context (fr and en) below. I figured out that it is encoded as base64. When decoded it's a gzip, which contains a .bmp which got xor encrypted. I need help to find this key. I have no hints about it https://tinyurl.com/needurhelpp Quelques minutes avant le crash de l'hélicoptère du GIC, le système d'imagerie satellitaire d'Osland a réussi à capturer une image de l'engin en perdition. ...

Help with defintions in my code (CS1061 AND CS0103)

I need help implementing some code that I found online. When I wrote the code in I got two error messages. (21,40): error CS1061: 'Transform' does not contain a definition for 'postion' and no accessible extension method 'postion' accepting a first argument of type 'Transform' could be found (are you missing a using directive or an assembly reference?) (22,9): error CS0103: The name 'directon' does not exist in the current context...

Threading issues, settter with ObservableCollection and ListCollectionView

I need assistance in understanding what is happening please. I have an ObservableCollection which I would like to filter according to certain buttons being clicked. (Complete/Busy for example) Now I created a ListCollectionView inside the set to handle the filtering, so the ListCollectionView will be shown on the UI while the ObservableCollection will be used as the data source....

Seeding DB for Integration Test

I am currently using TestContainers and WebApplicationFactory and am able to successfully setup a basic test which returns successfully. I am following the InProcess Example I am thinking of improving the way I populate data. Currently I populate in Program.cs ```...

✅ Recurring Access to Socket Forbidden by Access Permissions

I am plagued by this exception when trying to start up multiple ASP.NET web APIs in Visual Studio.
System.IO.IOException HResult=0x80131620 Message=Failed to bind to address https://localhost:44330. Source=Microsoft.AspNetCore.Server.Kestrel.Core...

✅ Ways to Add Language Support (WPF)

I'm creating a hardware monitor software that will show statistics of (primarily internal) components. There is a monitor and a settings user control to switch between the two. There are two user controls for the controls themselves and then a window, which is MainWindow that serves as the median between these two. How would I go about switching languages dynamically in my XAML when a selected ComboBoxItem for a language is selected, which is applied upon clicking on the apply button? Like methods of implementation....

Working on a car booking system, but the booking calendar isn't functioning properly

The Car Booking System is a MVC project where users can: - View a list of cars that are avalerble. - View details about a car (such as its title, model, image, and specifications)....

Appsettings not mapping to Options class

I could probably have worded the question better, but please bear with me. Also, this is not my code, and probably has not been set up properly, but other team members are all really busy. I see this in the Program class: ```cs public static IWebHost CreateWebHostBuilder(string[] args)...

✅ Correct approach and used in real life OLTP -> OLAP ETLCode first approach!

Hello I am trying to learn on making my very own business Web app it can contain many modules like grocery app, self checkout, restaurant app with OLAP features like getting interesting pie charts and other telemetry... I have done my own OLTP already but there seems to be almost non existent C# tutorials on how to create ETL the Datawarehouse code first approach. I was looking up BI snowflake but it looks like it's for people that already know what they are doing amd it's not code first. Any suggestions? ...

✅ Nuget Package Manager does not seem to be updating (How to Troubleshoot?)

So I'm getting an error on a sample project
System.InvalidOperationException : session not created: This version of ChromeDriver only supports Chrome version 106
Current browser version is 131.0.6778.265 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe (SessionNotCreated)
System.InvalidOperationException : session not created: This version of ChromeDriver only supports Chrome version 106
Current browser version is 131.0.6778.265 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe (SessionNotCreated)
...
No description

✅ Identity Help

I have a React Frontend where I'm doing OAuth with Google, and I wanted to pass along this signin to my aspnetcore backend. I've implemented identity and can see during the login process that my HttpContext.User has been set correctly with its basic claims. In the logs at that time I see this:...

Cannot implicitly convert int to string

```C# foreach (var kv in json["lines"]) // there might be a faster way to do this? looks like this algo is On^ NO ITS NOT { Dictionary<string, int> lyricMap = new Dictionary<string, int>(); string words = kv.words;...