C#

C

C#

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

Join

win32 island in wpf application has #f0f0f0 background colour

hii!! i'm working on a project which requires an embedded win32 control. however, the background of the island is always #f0f0f0 instead of #ffffff. this occurs even if the window is hosting no control and is just a child window. see the attached image for an example
No description

Forwarding calls to string.Create with custom culture info.

Hi. I have been trying to create a method to help us to do string interpolation using invariant culture. string interpolation picks up the current thread culture when formatting numbers and such and that can lead to surprises. ```csharp // x might be "0.00" but on my machine it is "0,00" var x = $"{0.00:0.00}";...

✅ Callable Class

```csharp using System.Dynamic; Run run = new Run(); ...

✅ this error makes no sense

getting a null reference exception here:
static Evaluation eval = new();
static Evaluation eval = new();
...

Exceptions.

We have the same code. When i type 4/3 my program crashes with the error (picture). When my colleague types 4/3 he gets it written to the output and the program continues. Why?...
No description

.NET MVC Project Issue

I'm unable to figure out why my ModelState is going False
No description

Managing Scoped Service Lifecycles with a Singleton Factory in .NET: Best Practices?

Hello everyone, I'm working on implementing a factory pattern for payment services in a .NET application and I'm unsure about properly managing the lifecycle of services. Here's the relevant part of my code: ```public class ProviderServiceFactory { private readonly IServiceProvider _serviceProvider;...

Blazor Isolated CSS not working

I have a Blazor app in InteractiveAuto mode and isolated css stopped working. I am not sure when it stopped working or what I changed. The attributes of the affected html elements are generated correctly. The generated css file contains the following:
@import 'ChemStore.Web.Client.bundle.scp.css';
@import 'ChemStore.Web.Client.bundle.scp.css';
I don't believe that the isolated css file is relevant since I tried removing all css I added myself, but I will provide it anyway: ```css #blazor-error-ui {...

Dependency Injection question

I was learning about coupling/decoupling and one thing that was confusing to me was this: Basically, people tell you to leave the instances for the calling of the constructor method, and instead just use an Interface that implements that class when using it on your code. The reason people will say this is useful includes (while not limited to) "Making so that if the signature of that class changes, the code using that class won't be affected, since it's using an abstraction of it, an Interface. Making it easier to change the class without breaking the code"...

C# backend vs Java backend

Hello, I will enter a long bootcamp and I am very undecided about which one to go with, there are 2 options in front of me, Java and C#. I could not decide even after my research on the internet. Can you please answer objectively, which way should I go?

problem with docker installation for .Net

Can someone please help me with solving this, the code has no error but the docker won’t install in the project
No description

creating a nuget for a custom msbuild task

I'm trying to follow the custom msbuild task tutorial here: https://learn.microsoft.com/en-us/visualstudio/msbuild/tutorial-custom-task-code-generation?view=vs-2022 My problem is that when using dotnet pack the resulting nupkg file doesnt contain any binaries. All required binaries are present in the ./bin/Release/netstandard2.0/ folder, they are just not packed into the nupkg. When inspecting the nupkg, there is no lib folder inside, i can see my .props file in the build folder though. Any ideas why that may happen?...

✅ Exception handling..

```cs namespace Calculator.Model { internal class Division {...

.MESH FILE CONVERSION

Hello, how would I go about converting Roblox .mesh files into Autodesk FBX Files with the use of Assimp via C# code?!

✅ SQL code

does anyone know why this keeps happening? i have tried changing the name to multiple things but it still says it is invalid
No description

calculated value in Start() function seems to be 0 when trying to use it.

Hi, i'm an amateur trying to learn c#. I'm confronted with a problem I can't seem to solve: I'm trying to use the "objectLength" value in the Start() function of my SpawnManager. I calculate "objectSize" in a different script called objectMovement. Now I know that it calculates the value correctly, but when I try to use it in the Start() function it is 0. (My Debug.Log(objectLength) outputs 0.) It must be a stupid error but I can't solve it. Thanks for your kind help!...
No description

✅ Different output on same code.

return arithmetic.Calculate(Convert.ToDecimal(left, CultureInfo.InvariantCulture), token, Convert.ToDecimal(right, CultureInfo.InvariantCulture));
return arithmetic.Calculate(Convert.ToDecimal(left, CultureInfo.InvariantCulture), token, Convert.ToDecimal(right, CultureInfo.InvariantCulture));
...
No description

✅ System.FormatException

Me and another are writing a RPN calculator. I get this error message when trying to calculate 3 4.8 5.7 + * 2.5 * but when he runs it he does not get an exception on it. We have the exact same files and code. Why?...
No description

✅ vs code community don't start my code

does anyone know how to fix visual studio code community that won't open my project? When I click on the run button it tells me everything was successful but in reality nothing opens, i am doing a Windows forms app and i am new with c# and vs code community