C#

C

C#

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

Join

✅ How to specify camel case for all response properties with Newtonsoft

This is the type of JSON I receive from an external API: ```json "phoneValidation": { "success": true, "data": {...

Refactoring Similar Network Requests

I have 3 async methods with a great deal of similarities but some differences (some use Authorization token, some have Json payload, some return Task<bool>, others Task) but all make network requests in a similar flow. What is an approach I could use to refactor them?...

Making Concurrent API calls Asynchronously (Is this Correct?)

Apologies for the long code, need to split it up into 2 posts because it's really long: ``` async Task SendUserInfoRequestAsync() { if (string.IsNullOrEmpty(sessionCache.loginToken)) {...

gRPC Reusing protos between projects

So I currently have 2 projects within my solution, lets just call them ServerP (Console app) ClientP (.NET MAUI app) I have got my proto definitions in the ServerP project and everything is happy days with it, it compiles, recognises the compiled files etc......

What is the quickest way to copy API structures (headers, payload, response) from browser inspector?

As per title. I'm calling an API that a different react app also calls, and it would be nice to see what structure they use for their payload/responses at a glance, particularly since some of the SWAGGER information is in a different language I am not fluent in. Right now I am manually selecting and copy + pasting (headers, payload, response), what is a faster or more sane way of going about this?...
No description

Pokemon Game SRP

Sorry I have a question about a game, I am making project for my uni about a pokemon game, the question is the next, I want to do the SRP principle of solid but I don't find a another posibility that make takedamage a method of each pokemon, is that bad? my setters are private because I don´t want them to be public, but I find that makeing and takeing damage should be a game mechanics class responsability

WPF Window -> SkiaGrid Coordinate Conversion Logic Problem

Howdy folk! I'm working on a WPF project that for a graphical editor using Skia/SKSurface/SKCanvas. In this application I am tracking the coordinates of where the mouse is, and draw a rectangle (as a cursor) on the grid overtop of the existing image....
No description

I need microservices project ideas

Hi everyone! I’m currently learning microservices architecture, as we don’t use it in my job. My primary tech stack is .NET, and I’d like to create a practice project that I can develop locally on Kubernetes, using RabbitMQ for communication within the cluster. Do you have any project ideas that would be good for practice?

Homework for me

i will show you very soon what i need to do hum i'm not a pro ( sorry for the english i'm french)

Get 16 bit floating point precision as a ushort

I saw on SO that using Convert.ToUInt16(2.2) would give me the 16 bit representation of the float, but instead it just gives me 2, what is the proper way to do what i want?

Out Parameter Question

I think this should be simple, but I am coming up blank on a method call with an out parameter. (The example below is basic but my actual code requires the parameters) File1.Cs ``` class Example...

Get minimum bytes needed for a number in c#

I have this method in python that gives me the minimum bytes needed for a number
def get_time_byte_size(self, time):
return (time.bit_length() + 7) // 8
def get_time_byte_size(self, time):
return (time.bit_length() + 7) // 8
...

implement stripe payment feature for asp.net core web api and wpf

so I am trying to add a payment feature using stripe but it takes me to this page for some reason I am not sure how to fix it here is my code ...
No description

WPF running .ToString() of viewmodel instead of showing the coresponding view

For the context, the app is implementing mvvm and i have: a viewmodel named CheckViewModel and a corresponding view, some base classes like BaseViewModel, ObservableObject,etc and navigation through a interface and a class that implements that interface My problem rises when I run the app. I Expect to get the view for CheckViewModel, which have some UI elements there but instead i get on top left corner the .ToString() method from CheckViewModel. In the App.xaml i also have a defined resource for that view App.xaml: ```cs...
No description

Trigger isnt working

I can have the 2 box colliders overlapping and it still isnt triggering
No description

✅ Default interface methods - Am I using them wrong?

I'm trying to learn when/where to properly use interfaces, and I don't understand why my default method doesn't work. I have this: ```c# public interface IMyInterface {...

Can't build anything in dotnet 8. Not even template project.

I get this error when i try to build any project on Ubuntu 24.04 The project has just been made with dotnet new classlib ``` relt@relt-MS-7D95:/media/relt/M2/Blendesonite/test$ dotnet build MSBuild version 17.8.5+b5265ef37 for .NET...
No description

Firefox browser in c#/c++

The question is not entirely about C#, but rather about whether it is possible to integrate the latest versions of the Gecko core and, for example, write a browser for it using C#?Or only C++? Are there any good libraries? How difficult is this for an average C# dev?...

✅ .NET 9.0 | CSharp - WinForms | Encryption & Button Function Issue

Having a minor issue when trying to encrypt a file. This is my exception error that was thrown: Error: Method or operation is not implemented Here is my button call code:...