C#

C

C#

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

Join

getting tcp connection state

im currently in following situation: we have a tcp architecture where more or less everything can connect to (local network). since devices conencting arent always behaving properly we cannot bet on graceful connection closing. as a workaround we are polling on IPGlobalProperties.GetActiveTcpConnections to forceclose connections and require a new handshake and datasyncing. we have the problem now though that with increasing amount of tcp sockets in windows (checked via netstat) that call gets rediculous slow and cpu heavy. more or less all i need is to check that the connection that is/was connected is still estabished. are there any alternatives i could use? would p-invoking GetTcpTable be faster? are there better apis?...

Why is `dotnet publish` not including Roslyn for my ASP.NET Framework 4.8.1 Web App?

I converted my .NET Framework 4.8.1 Web Application to SDK-style projects (like Microsoft recommended). I think I've worked out all of the quirks except for the publish piece. For some reason, the publish likes to modify my web.config and add stuff to it not included in the original. It also is not including the roslyn folder in the bin folder in the published output. ANYWAY. I worked around the web.config getting molested. Now I just (I think) need to find a way to include the bin\roslyn folder in the published output....

Selenium-unable to find element

Trying to run TestLogin(1st test) inside TestAddToCart(2nd test) then find an element afterwards, but unable to. I was able to find the element in the first test, but it doesn't seem to work in 2nd test. Not sure if it is allowed or there needs to be some kind of wait time. [Test] public void TestLogin() {...

Inconsistent accessibility: parameter type ''x" is less accessible than "y"

I'm getting this weird error here. Probably some namespace wizardry i'm not aware of.
No description

✅ How to send Email or SMS message text

Hi. How could I send an Email or SMS message text using C#?. I tried with next code but doesn't work. I am using my GMail account. Thanks in advanced....
No description

Grid Layout

```cs else if (entercount == dialogue.Length && printcount == dialogue.Length) { Console.Clear(); for (int height = 0; height < 15; height++)...

SVG Icon in a wpf App

Hi, I found SharpVectors and I wanted to know what is the best way to use SVG files for icons in a WPF app. The current solution I went through was to save all the uriSource in a ResourceDictionary and then use it that way: <svgc:SvgIcon UriSource="{StaticResource IconSettingsPath}" />...

WPF Video Editor program | Help with the (Timeline/TimeMarks)

Hi there! I am in need of help making the timeline and time marks for my program. I personally tend to struggle when it comes to math(dyscalculia hates me) so the concept of this is really not clicking for me!...

*"Converting possible null value to non nullable type"* warning in `Console.ReadLine()`

Can I ignore "Converting possible null value to non nullable type" warning here:
string s = Console.ReadLine();
string s = Console.ReadLine();
...
No description

Guide or Reference for Quality UX With CLI Applications

Are there any good references or guides on designing CLI command structures for high quality UX and ergonomics? Like when to use arguments, when to use options, how to expose a choice as an option, etc.

LEARN C# in 2025

hi this might ve been asked 300 times. i already have a experience with prog languages, no idea about csharp or anything like it where should i begin, but to note my goals are Unity GameDev and .NET industry (lacking a cs degree)...

I need a help I had 10 years experience in C# and .Net , Entity Framework, WPF

I need a help I had 10 years experience in C# and .Net but I dont had knowledge or courage to switch to another company since I dont had knowledge from scratch. I can work any modules or function if they explain but I cant built from scratch so Im requesting everyone here to help me to gain insights and knowlede and advise me or give me roadmap so that I can achieve my dreams. Please help...

Acrylic

Does anybody knows how to make my winform form background acrylic blurry transparent effect

Serilog Confusion

Trying to implement Pope's code and I'm messing it up 😦 https://paste.mod.gg/yywrpkzeacxd/1 @Pope I'm trying but getting confused. 😐...

Bubbel sorting

I need to do a bubble sort after given instructions, i understand nothing. Could someone help me where i can find good informative information on bubble sort, the book i have dosent really go over bubble sort that well.

Relation Does not Exist when running Tests

Hi, trusting y'all are well. So I am runnin into this issue where my XUnit tests using a Postgres Test Container fail with the error message
Npgsql.PostgresException : 42P01: relation "Accidents" does not exist
Npgsql.PostgresException : 42P01: relation "Accidents" does not exist
. I have an extension method
Apply Migrations
Apply Migrations
that should run the migrations when the container starts. I'd appreciate your aid, thanks!
No description

Saving Messages withj SignalR

Hi guys Im Creating a webApp for creating groups something like discord and skool.For now i have the basic home page Creat Group and visualzing the group to some degree(Im dump and made the frontend first).I use SignalR the chat system and have TextChannel and Message models in the Db.I want to save the messages and display them.How can i do that with the SignalR. Here is the repo https://github.com/MiroslavPetrovv/GroupApp

SignalR : Websocket connected twice on connection.

Hello, On my current project (frontend : ReactJS / backend : .NET 9) when I successfully connect to my SignalR hub, it connects twice, as shown per the screenshot. I can't find any clue on the internet of why this is happening. Does someone knows how to solve this ? Thanks....
No description

Resource to learn making GUI in C#

Hello guys, is there any recommended resource to start making GUI from scratch in C# please

✅ How to convert controller route name to camel case automatically?

I have this: ``` [Authorize] [Route("[controller]")] public class StreamController ...
Next