C#

C

C#

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

Join

โœ… Help with Tooltip content binding

I have created a UserControl with dependency Property to accept the string for the TextBlock within my ToolTip XAML: ```xml...

How to make sliding panel animations in avalonia using xaml ?

title i have a panel but i want to add a sliding animation to it. how?...

MemoryMarshal.Cast on a struct with array of known fixed size

I'm wondering if there is some way to marshal a byte array into a struct that is known to be of fixed size, or has known length values via other fields: ```csharp using System.Runtime.InteropServices; using System.Text.Json;...

Help with Entity Framework Core: Union of Two Queries with Inherited Types Failing

Hi everyone, Iโ€™m working on a project using EF Core and AutoMapper with HotChocolate for GraphQL. Iโ€™m trying to combine two queries using Union, but I'm encountering an error. Scenario:...

โœ… ASP.NET Core SSL not working.

Whether it is the port generated by visual studio or my own custom port, I get an error page in Google Chrome (image attached). Any help is greatly appreicated, thanks!...
No description

Best Way To Load and Cache Scoped Data?

I am using MediatR, so scoped services essentially live the lifetime of the MediatR request. Given that, I want to load configuration from a database if not loaded (using Entity Framework), then cache the returned data, as it is used multiple times for the request. What is the best way to go about this? This is my current code, but this is blocking and I would think could cause performance issues. ...

did i code right?

The assigment was to get the stack of class couple that has number and appears, and im supposed to return a stack that has numbers from low at the bottom to high at the top, and each appear the number appear for that number, so for example for 1,2 0,3 it would return 0,0,0,1,1 did i write the code right? Does it work? How can i improve it, its probably too long
No description

Compiling C# without Visual Studio

I'm new to C# and I understood that if i want to compile code without Visual Studio i need to use Roslyn, but on github it marks the latest release as .NET 6.0. Is there no way to compile C# code with .NET 8.0 as it is the latest LTS release? Visual Studio is very heavy, especially since i don't intend to use C# for big projects and my system isn't too performant.

Writing to text files

I've tried looking up what the static type means but it just isn't clear to me. Does someone have a good explanation of what that type indicates?

MySqlException: Field 'CreatedOnUtc' doesn't have a default value

So I have been creating a very simple ASP.NET Core application lately with a simple mariaDB configuration and nginx Once the dotnet run has been typed, a web app pops up on Chrome prompting me to enter login credentials. As the combination of root-root (for both of username and password) is not allowed there, I opted to create a new user. The web app now prompted me to create brand new credentials (email, password, username). Once those have been entered and the submit button has been hit, the following error got triggered...

โœ… User defined Exception Handling

```cs namespace Workshop3.Menus { public class ReadTextFileMenu : Menu {...

i dont know much about reflection and im having problems

i would appreciate it if someone could help the pic2 is what i want to achieve...
No description

โœ… Can't infer type arguments from usage

I was looking into writing an extension method to Flatten nested collections, as I always forget that SelectMany(i => i) exists (and also personally think it's ugly/non-intuitive). Said method looks like so: ```cs public static IEnumerable<TValue> Flatten<TOuter, TInner, TValue>(this TOuter items) where TOuter : IEnumerable<TInner> where TInner : IEnumerable<TValue>...

โœ… Reading a file

Problem description: In the file TextFileReader.cs (in the folder IO), you will find a code skeleton for the class TextFileReader. Implement the functionality to read text from a text file. It should be possi- ble to use the class from a client (another class), where the client can enter a path to the text file,...

Increased I/O utilization after new version deployment

Hello, maybe someone will have some ideas, because I'm running out of them. New application version was deployed to production and we noticed increased C and D disk utilization. Reads/writes remains the same, but utilization skyrocketed. Couple days of not paying much attention we got total VM crash, CPU hit 100% and everything froze. Not sure about previous % Time in GC statistics, but current one looks awufly high. Turning service off does not reduce utilization, tried waiting 30min. Only server reboot helps to fix it. ...
No description

โœ… help with assignment

I am coding a RPN calculator and I am supposed to do the calculator.view part and I just want to make sure I am doing it right. This is the code I have written so far and I attached the instructions. //Calculator.view// using System; using System.IO;...

Reading from a textfile

How does it work? Everywhere I look itโ€™s different