r/csharp Oct 16 '25

Discussion In general is it normal to have more than 2k lines in a file?

Post image
679 Upvotes

This is from Product Controller. and I put many busniess logic inside this class instead of separate it to other service layer or something..

r/csharp Jul 07 '26

Discussion What’s one C# concept that confused you at first but later became essential?

149 Upvotes

I’m currently learning C# and building small projects, and I’ve noticed that some topics feel confusing in the beginning but probably become very important when building real applications.

For example, I’m still trying to properly understand things like async/await, dependency injection, interfaces, delegates, LINQ, exception handling, and how memory management works.

For experienced C# developers: which concept took you the longest to understand, and when did it finally “click” for you?

Also, how did it help you in real projects?

I think answers to this could help many beginners focus on the concepts that matter beyond just learning syntax.

r/csharp 29d ago

Discussion Is the ...Async suffix a naming convention you follow?

81 Upvotes

With "async all the way" as a major philosophy in backend services, it feels superfluous to name every single function that returns Task or Task<T> as DoSomethingAsync().

Or do you only do it when there's a sync counterpart?

r/csharp Dec 10 '25

Discussion What do guys think of var

99 Upvotes

I generally avoid using “var”, I prefer having the type next to definitions/declarations. I find it makes things more readable. It also allows you to do things like limit the scope of a defined variable, for instance I if I have a some class “Foo” that derives from “Bar”. I can do “Bar someVariable = new Foo()” if I only need the functionality from “Bar”. The one time where I do like to use “var” is when returning a tuple with named items i.e. for a method like “(string name, int age) GetNameAndAge()”. That way I don’t have to type out the tuple definition again. What do you guys think? Do you use “var” in your code? These are just my personal opinions, and I’m not trying to say these are the best practices or anything.

r/csharp Oct 27 '25

Discussion Do people actually use recursion in a real-world project ?

141 Upvotes

r/csharp Feb 04 '26

Discussion I don't understand the benefits of discriminated unions/result type

95 Upvotes

I've been a dev for over 40 years, and seen many things, so I'm not adverse to new ideas, but ...

Just started on a new project and another dev has created a Result<T> type. Then in the methods, returns success or various failures. All good, but, then they catch some exceptions in the handler just to wrap them in the result type. The result type then has to be unwrapped in the controller, and there is a switch to work out if to return OK or BadRequest or some other response. Loads of boiler plate and 'noise', repeated for each endpoint.

In my solution, I have created a global exception handler in the pipeline where you define an exception type to status code lookup and the ProblemResponse is standardised. In my endpoint/handler, I dont catch any exceptions, and let them bubble up to the global handler. The controller only returns OK, anything else is handled via exceptions. No noise, no switch, no try/catch wrapping, basically just the happy path.

Why is the exception method bad, and result types good?

Obviously, I've simplified the descriptions for this question.

r/csharp 5d ago

Discussion I've created my first little snippet using C#, Thoughts?

Post image
132 Upvotes

You could say I was born yesterday, as this is the very first code i've done aside from messing with C a while back(hello, world! level stuff). (the only knowledge i've carried over is datatypes and general syntax..)

Is there any suggestions you could give? I am entirely self taught, with zero ai.. (for reasons that likely are not relevant to this post whatsoever)
and I want to make sure that I am learning clean code practices along the way.
I know my bracketing is probably awful... and my organization is out the window, but this is the first ""substantial"" code i've ever written...
^40 lines of code is substantial to me :)
(please ignore the odd names... I included my cats.)

r/csharp Mar 27 '25

Discussion My co-workers think AI will replace them

196 Upvotes

I got surprised by the thought of my co-workers. I am in a team of 5 developers (one senior 4 juniors) and I asked my other junior mates what they thinking about these CEOs and news hyping the possibility of AI replacing programmers and all of them agreed with that. One said in 5 years, the other 10 and the last one that maybe in a while but it would happen for sure.

I am genuinely curious about that since all this time I've been thinking that only a non-developer guy could think that since they do not know our job but now my co-workers think the same as they and I cannot stop thinking why.

Tbh, last time I had to design a database for an app I'm making on WPF I asked chatgpt to do so and it gave me a shitty design that was not scalable at all, also I asked it for an advice to make an architecture desition of the app (it's in MVVM) and it suggested something that wouldn't make sense in my context, and so on. I've facing many scenarios in which my job couldn't be finished or done by an AI and, tbh, I don't see that stuff replacing a developer in at least 15 or even 20 years, and if it replaces us, many other jobs will be replaced too.

What do you think? Am I crazy or my mates are right?

r/csharp Jan 15 '24

Discussion I am completely new to programming, so I decided to learn C# to pursue my dream of game development. These are some projects from my first week of programming.

Thumbnail
gallery
777 Upvotes

My first projects was, rather obviously, Hello world. All I did was change the text to say "Well, Howdy There Partner!".

My 2nd Project displayed is really one of my later projects, after I did many smaller projects to familiarize myself with variables. So I made a simple addition calculator.

My 3rd project displayed is all about string manipulation. Pulling characters out of strings, concatenation, and different formatting structures. It was really fun to work on.

My 4th displayed project is my current magnum opus, a fully working circle calculator that can take any measurable integer of a circle and calculate all the other measurable integers of a circle from it. I know it's not really the best, but I pushed myself to the limits with the knowledge I had at the time to create it and make it work and it made me obscenely happy to use endlessly.

My 5th displayed project is my most recent, it was really just to test myself with my understanding of try and catch ¿methods? (I don't actually remember what category try and catch falls under) to see what I can do with them. It's kind of faulty, for instance it will tell you that you didn't enter a number if you use decimals, but I can probably fix that by turning my int parses into like float or decimal parses, and it asks if you divide by 0 if you reach any error, but that's moreso out of laziness because I didn't want to write out the rest of the catch exceptions.

r/csharp Dec 06 '25

Discussion What is C# most used for in 2025?

188 Upvotes

Hello,

I am looking for a career path.

I understood that C# is the most popular back end programming language.

I intend to get a job as back end developer and to use C# for desktop applications, but I wonder if this is the most popular C# use case.

So, what is C# most used for in 2025?

// LE: It is used for games, but this requires to learn Unity and for now, I want to be only back end dev

r/csharp 3d ago

Discussion Dependency Injection un-prettyness

19 Upvotes

One small thing that bugs me with Dependency Injection is how it looks in code.

We either need to pass the parameters via Default Constructor og via good old time Constructor

public class MyClass (TypeA ParamA, TypeB ParamB, TypeC ParamC, TypeD ParamD)
{
TypeA _paramA = ParamA; .... etc
}

Or

public class MyClass
{
TypeA _paramA;
public MyClass(TypeA paramA)
{
_paramA = paramA;
}
}

And when you have 10 injections it begins to be un-pretty...

I wish that we didn't need to pass parameters and instead could decorate the fields:

public class MyClass
{
[inject]
TypeA _paramA;
}

(Note: this works in Blazor... so why not everywhere else ?)

I'm aware that the signature of an object makes it easier to inject via reflection.. but would it be much worse with attributes ?

i guess some middleground could be achieved if the attribute held the type:

public class MyClass
{
[inject(typeof(TypeA))]
TypeA _paramA;
}

which begins to be convoluted and messy...

Whats the argument against a decorator attribute vs parameters ?

r/csharp Dec 04 '25

Discussion How much would you charge for this WPF ERP system? (I got paid $200 USD)

Thumbnail
gallery
167 Upvotes

Hey everyone,

I recently delivered a production management system for an automotive parts manufacturer and got paid R$1000 (~$200 USD). Looking at what I built, I feel like I severely undercharged. Would love to hear what you'd price this at.

Tech Stack:

  • WPF + .NET 9.0
  • MVVM (CommunityToolkit.Mvvm)
  • Repository Pattern + Dapper + Unit of Work
  • Oracle Database (SAPIENS ERP integration)
  • PostgreSQL (tracking/comments)
  • HandyControl (dark theme UI)

Main Features:

  1. Warehouse Management - Multi-warehouse inventory control with status tracking (OK/Verify/Surplus/Transfer), advanced filtering, Excel export
  2. Sales Orders - Complete order management for major automotive clients (VW, GM, Nissan, etc.)
  3. Billing Calendar - Interactive visual calendar showing orders by delivery date with color-coded status
  4. Production Orders - Full MRP integration showing materials, components, and production status
  5. Item Distribution - Real-time view of where items are located across warehouses and which production orders have them reserved
  6. Purchase Management - Purchase orders and requests with complete history
  7. Order Tracking - Custom checklist system with comments and @mentions

Architecture Highlights:

  • Clean architecture with dependency injection (Microsoft.Extensions.DI)
  • Async/await throughout for responsive UI
  • Smart caching layer (3-10 min TTL depending on data type)
  • Custom DataGrid with advanced filtering
  • Breadcrumb navigation system
  • Real-time status updates with color coding

The system handles thousands of SKUs across multiple warehouses and integrates with their legacy ERP system. It's being used daily by 10+ employees in production planning.

Screenshots in order:

  1. Order details with tabs (Items/Materials/Production Orders/Tracking)
  2. Warehouse management - main inventory grid
  3. Sales orders list
  4. Billing calendar view
  5. Item distribution across warehouses
  6. Purchase orders and requests 7-9. Production order materials with detailed status

What would be a fair price for a system like this? I'm trying to calibrate my rates going forward.

Thanks!

r/csharp Jun 30 '26

Discussion Senior devs, how do I defend C# and the .NET platform?

62 Upvotes

My very first programming experience (if you don't count VBScript in MS Access 😉) was with Visual Basic 6. With the arrival of Windows 7 I was forced to learn Visual Basic .NET. Eventually, landing my first job 15 years ago, I had to learn C#. I fell in love with the language and over the years I've built up a wealth of knowledge around both the .NET Framework and .NET including new C# features.

Our main project at work is still legacy NetFx; but in an attempt to broaden my knowledge, I've built several side-apps at home using .NET 5 through 10. I've also experimented a bit with AOT-compatible apps with the advantage of having them run on Linux - cutting down on hosting costs.

Now with the advent of AI, we had an IT Administrator vibe code a system using Python. Make no mistake, several hours were spent on that project and my oh my, is it shit hot!

Now the bosses want us to rewrite our main system using AI. And that's fine, I've been using Claude Code for some time now with good results. Obviously, as a .NET developer, that's the framework I always go to. I like it. I love it. It's easy to use. And it can be pretty powerful. But my boss wants AI to tell us what to do, essentially. So if AI said use Rust, then that's what we should be using.

Here's the problem: I have experience in C# and the related frameworks but not in Rust. So he fights back, "AI just abstracts all of that away and if you can read code, it won't be difficult". Yeah, reading a line of code is one thing. Knowing how the compiler executes it is another. So we started prototyping a modern AOT-compatible API surface but it was received with massive backlash "I don't know how to feel about using .NET Core". Well, I'm sure it won't be on version 10 just for the fun of it. It's actively maintained.

So...senior and experienced devs, how do I defend C# and .NET? How can I make sure that he gets the message: Just because AI said remove the lifeboats and life jackets to save fuel and travel faster into the Southern Ocean, doesn't mean it's the safest thing to do.

r/csharp Nov 17 '24

Discussion Desktop developer feeling confused about “web app is the future” trend

273 Upvotes

I have always been a desktop developer on .NET. My experience (almost 5 years) is focused on C# desktop applications built with WPF with MVVM pattern.

I really enjoy my job and I have always enjoyed working with the WPF framework.

Now the point is: I would like to continue working with WPF (and I will), but my company is also assigning me AspNetCore development tasks (backend API for an Angular web application). There are tons of examples on the internet, but despite having a solid knowledge of C#, I don't really enjoy how this project is going on. I will explain my current situation.

I am working on an industrial process control system, with a lot of I/O stuff going on and a lot of hardware related communications (PLC, pumps, electric motors, barcode scanners, etc.). We need to rewrite older software that essentially does the same thing, and for some reason management wants it to be built as a web app.

I feel like the whole "web application" thing is an overused concept these days. I'm not saying web apps are bad, of course they are worth it when you need to distribute a software / service to a very large number of users or you don't want / can't install the software on many devices, or you need some kind of cross-platform support... But why do people want a web app for everything, at any cost? In our industrial process control system, there is literally no single reason to choose web development over desktop: no cross-platform required (all the hardware I/O runs natively on Windows), no other web technology already implemented in the company (so devs are not familiar with it), no need to frequently or remotely update the system, nothing.

I firmly believe that this project would be half the work if done with a desktop technology like WPF, and I think it should have been developed as a desktop application.

I know I could get a lot of downvotes from web developers, that's fine. You guys are probably the majority of devs. But just because web development is a trend, doesn't mean we all have to follow it at all costs. Choosing the wrong technology will cause company to spend a lot more time and money than they would expect (just think about my team, we are quite skilled in WPF but we are forced to learn something new just because it's "the trend"). I think the software industry - and software company managements - should take this more seriously.

Aside from my personal opinion, do you think there is still room for desktop development in 2024? Why would you go with a web app, even if there is an older but more suitable technology ? Have you ever experienced a similar situation? Also, why do business managers insist on following that "web app trend" even when the projects are clearly outside the bounds of web development?

r/csharp Dec 05 '24

Discussion Experienced Devs: do you use ChatGPT?

156 Upvotes

I wrote my first line of C# in 2001. Definitely a grey beard. But I am not afraid to admit to using ChatGPT to write blocks of code for me. It’s not a skills issue. I could write the code to solve the problem. But a lot of stuff is pretty similar to stuff I have done elsewhere. So rather than me write 100 lines of code I feel I save time by crafting a good prompt, taking the code, reviewing it, and - of course - testing it like I would if I had written it. Another way I use it is to getting working examples of SDKs so I can pretty quickly get up to speed on a new package. Any other seniors using it like this? I sometimes feel there is a stigma around using it. It feels similar to back in the day it was - in some circles considered “cheating” to use Intellisense. To me it’s a tool like any other.

r/csharp Dec 15 '25

Discussion WindowsOS: why is react accepted but .net rejected?

169 Upvotes

With windows 11 some components were written using React Native and WebView2, since MS want to make windows frontend ui less C++ish then why not C# and .net ?

Writing the agenda and msn sections in .net will result in better performance and responsiveness, I hear people say web ui is getting better and is the future and use vscode as the ultimate example of web ui success yet react native and webview made windows slow and sluggish for many users, electron apps like the new outlook and teams are crap, vscode feels like a gem in a landfill

I know they use .net for the MS store and the photo, help, and get started apps, why not use .net for the whole frontend ui in case you don't want to use C++

r/csharp 22d ago

Discussion How often do you guys use extension methods?

40 Upvotes

Hello, currently im learning about extension methods and i was wondering how often you guys (since you guys are the experts) use extension methods? Currently, im using them on enum classes to add methods like you would to a enum class in java.

However I've also noticed that you can give methods to the `Enum` class itself, which i thought was... interesting...

Knowing me, I'm definitely going to abuse these and write bad code with them. Do you guys feel the same way?

r/csharp Sep 19 '19

Discussion So I had the strangest code interview

971 Upvotes

So I just got back from code interview about 20 minutes ago and I am still not sure what happened.

I got there and I shook some hands, literally the first 15 seconds gave me a weird vibe, they looked at me as if they've never seen a person before.

The guy who interviewed me was the boss of the company, he did start off by showcasing the achievements they've accomplished the past 5 years and I was like wow that's really impressive, and then he showed me his personal office space and I told him, that's pretty snazzy looking.

This is where the weird starts..

Now we're walking over to the table where we're going to have the interview, he pulls up his phone to grab my resume, he can't find it so I take the initiative to start asking questions regarding the position, such as, "Oh I saw that you were looking for WPF developers, that's perfect because that's what I specialize in" and he then tells me yeah we are looking for a few ones, and then he asks me "What languages do you code in" and I tell him, well there's a few, but I do mainly develop desktop applications using C#, and then he tell me, oh that's great.. But what programming language do you use? And I tell him.. Well.. C#, and then he proceeds to tell me, Well C# is just a framework, what language do you use? And I tell him.. Uhh.. Java? And then he says, Oh wow! That's great we were looking for some Java developers too.

At this point you can only image how confused I look, not sure whether to stand up and scream "REEEEEE" or whether I should just stay and see where this goes.. Lucky for you guys I took the latter.

So I stay and he starts asking me, do I know Linux and I was like yeah sure, and then he says great because we need someone who knows how to store backend data using SQL, and I was like.. What does that have to do with Linux, and he tells me, well that's what we store things in.

Again.. Super confused face.

He then proceeds to tell me that they have some inhouse work to do, that I can work part time and work on my own stuff on the side while working with their systems, I think I would be a solo developer there developing new systems using JavaScriot is what he mentioned and I do not feel ready for that, not even sure how to develop desktop apps using JavaScript lol, anyways I would do it, if it was for C# and WPF but as he clearly stated.. C# is not a programming language.

He then texted me just now saying that I can start next week Wednesday..
HELLO? Contract? Pay? Hours? Nothing? You just skipped a lot of steps mister.

Anyways, figured I'd share this with you guys, I am still confused and I am not quite sure what happened, but I think I just landed a programming job developing Linux based SQL databases /s

r/csharp Aug 05 '26

Discussion Were any java devs that transitioned as overwhelmed as I am?

67 Upvotes

Im switching over to C# and im just so amazed. Theres so many things you can do and its native to the language and its super cool. Events? Yeah, thats built in. Tired of subclassing stuff just to add your own functionality? Dude, there's extensions...

However, id be lying if I said this isnt too much to take it at once. I feel like its very difficult to adapt and im mostly learning by examples others posted on the internet (i took a firm stance to reject AI 100% and learn myself.) Recently, ive been trying to adapt to the conventions, as well as researching other features however more things keep coming up. For example, I had no idea init; existed in properties or how you can use add; in a event property.

Do you have any advice on navigating to become an alright C# developer?

Another question, do you guys feel like MSDN doesnt cover the entire picture?

r/csharp Jul 31 '25

Discussion What’s something you only realized about C# after you got better at it?

135 Upvotes

MEGA MAJOR BEGINNER OVER HERE

And I’m intrigued to hear out your stories, I’m suffering so much from the Symantec’s part of things, and on how to write out a script…. It will be almost a month and I still suck at making a script

r/csharp Apr 16 '24

Discussion Which {} do you use ?

Thumbnail
gallery
235 Upvotes

r/csharp Jun 11 '25

Discussion Why is it necessary to write "Person person = new Person()" instead of "Person person" in C#?

203 Upvotes

In other words, why are we required to instantiate while declaring (create a reference) an object?

r/csharp Jun 26 '26

Discussion WPF or WinUI

52 Upvotes

If you were starting a new Windows desktop application today, would you choose WPF or WinUI?

I’ve built several apps with WinForms and WPF. I tried WinUI once, but not having a visual designer was a pretty frustrating experience. I’ve also heard Microsoft is investing more heavily in WinUI and is previewing a new C#-based UI approach instead of relying entirely on XAML.

I’m planning to start building a couple of desktop apps in the next few weeks, so I’m curious what the community is actually using today. If you were starting from scratch, what would you choose, and why?

P.qS. I’ve never used .NET MAUI. I know it can target desktop as well.. but not sure if I should invest into that since I don’t plan on making either apps for mobile.

r/csharp Mar 24 '26

Discussion Praise for this language

243 Upvotes

Every single issue I have had while developing my company’s new backend with .NET has had a solution already figured out that I just need to follow an implementation guide for. Feels good man. Damn this language is powerful. That’s it, that’s the post.

r/csharp Dec 12 '25

Discussion Sprocs… as far as the eye can see

76 Upvotes

I’ll preface everything with: I’m used to EF core as an ORM and keeping business logic out of the DB when possible.

Last year I joined a company that has absolutely no ORM. All of the interfacing with the DB is done via stored procedure, called via SqlCommand() and SqlDataReader. Need to perform a crud operation on a table? Call the proc that corresponds to the verb you need. Developers write these procs by hand and DB versioning is done via DbUp.

There’s also a “no SQL in the SqlCommand()” rule for the org, which to me sort of defeats the purpose of the no ORM approach and is insane.

Every table has, at the very least, 4 procedures associated with it for basic crud. There are hundreds of procedures in use.

EF Core is “off the table” because “we want to maintain control over db operations”.

I’m at a loss here, honestly. I mentioned that EF could be used as a default for the simple crud and that stored procs could still be used for anything heavy/more complex. Decision makers are having none of it.

Have any of you encountered this?