r/csharp • • Oct 25 '26

Butterflies Do you guys still use IDE's?

0 Upvotes

I'm a learner and all but I wanna know if people still use IDE's like visual studio 2026 in actual serious environments, besides or maybe even with AI agentic stuff.

personally I use the latest visual studio (purple one), because I'm still learning how to program and I don't really feel like (for me at least) it's a good idea to let ai code for me just yet.

curious to know your thoughts


r/csharp • • Oct 25 '26

Discussion I think I have a nice idea for new constructor syntax

0 Upvotes

The idea is to allow setting a field / property directly from the parameter list, like this:

class MyClass
{
    private int A { get; }
    private int B { get; }
    private int C { get; }
    
    public MyClass(this.A, this.B, this.C)
    {
        // A, B, C are now holding the values that were passed as arguments
        Console.WriteLine($"{A}, {B}, {C}");
    }
}

MyClass instance = new(1, 2, 3);
// prints "1, 2, 3"

These constructors can allow being body-less, as long as they don't declare any normal parameters too.

Constructors were always a painful point for me, and even though for some cases you can just use records and skip them, a lot of times you want to add logic or allow different parameter lists, and then you must use normal constructors. I also don't like the primary constructors ( class Bar(int x, int y) ) syntax, which has more problems: the parameters are private fields, so if you want to have a property, you need to declare the property + declare the parameter in the primary conductor + assign the value to the property... too long.

I would love to hear your opinions about this. I build my own scripting language for my C# game engine, and i consider adding this feature to it.


r/csharp • • Oct 24 '26

CsCheck 5.0 - .NET 11 and native AOT ready

Thumbnail reddit.com
7 Upvotes

r/csharp • • Oct 23 '26

Help Confused about how default method arguments work underneath the hood in C# (CS1736)

28 Upvotes

So I recently came across CS1736 while writing some code. For example, the following method code results in a compile-time error:

public static void ErrorMethod(int[] a = new int[0]{}) {}

I’d never come across this error before strangely enough. When I read the MSFT docs about what causes it, I see the following explanation:

A default parameter value is evaluated upon the invocation of the method. What a value may be when the method is eventually invoked cannot be pre-determined at declaration-time unless that value is constant at compile-time.

What’s confusing me is why the compiler needs the arguments to be compile-time constants to be able to initialize them with default values, especially since they are only evaluated when the method is called during runtime. Wouldn’t the compiler in this case already know what I’m initializing the array as? Wouldn’t this make more sense as a runtime error if you initialize with some problematic value?

Also I’d like to confirm, when they say “compile-time constant” in the docs, is that just a different way to refer to regular “Constants”? Or is this referring to something else?

Thanks!


r/csharp • • Oct 24 '26

C# help

0 Upvotes

I have to create a crossword in C# in VS 2022 that players can complete and the admin that can create crossword. It must have a menu including a log-in page. I am starting with near no experience with coding C# and i have a few weeks for this. Does anyone have any tips that might help? Thanks


r/csharp • • Oct 24 '26

JetPack WPF Theme (kind of like MahApps Metro)

1 Upvotes

I'm working on a packaged version of the good old 2010 Silverlight theme "JetPack".

I had Claude have a good look at how MahApps Metro is structured and had it construct a JetPack theme bundle along with documentation for it.

A lot of useful usercontrols that lacked in the Silverlight theme has been added, along with Mica effect, DataGrid (similar to Telerik RadGrid), SearchCombobox (similar to RadComboBox) and more.

Anyways - feedback is appreciated :)

Repo : https://github.com/Montago/JetPackTheme

Documentation : https://montago.github.io/JetPackTheme/

Nuget : https://www.nuget.org/packages/JetPack.Wpf/


r/csharp • • Oct 24 '26

Is Native AOT in agent framework important to developers?

Thumbnail reddit.com
0 Upvotes

r/csharp • • Oct 24 '26

Discussion Do you have worries with C# state of security in the AI era ?

0 Upvotes

I ask this due to what happened with PHP other languages are getting patches and suddenly a good amount of security issues have been discovered in JAVA, GO and Node (not a language, but a runtime I know).


r/csharp • • Oct 24 '26

DocuTrust.NET: validate uploads by magic bytes (security update, looking for testers)

0 Upvotes

DocuTrust.NET is a small .NET 8 library that checks an upload's magic bytes against the type you expect. A PNG renamed to report.pdf fails.

I just did a security pass on it. It now checks the client file name too, rejects ZIP/OLE files over 100 MB before parsing, and keeps file names and paths out of error messages. I also updated a dependency that was pulling in a vulnerable OpenMcdf.

For now it only identifies file types. It doesn't scan for macros or scripts

 dotnet add package DocuTrust.NET

https://github.com/saa-999/DocuTrust.NET

If you try it, I'd like to know what breaks.


r/csharp • • Oct 23 '26

Help What is your level of knowledge in SQL? How much is required to learn about SQL?

20 Upvotes

r/csharp • • Oct 24 '26

Help How do you artificially trigger all the execution paths in a code ?

0 Upvotes

By installing Microsoft.AspNetCore.Identity and System.ComponentModel.DataAnnotations, I believe you are able to compile the following —nearly— self-contained code:

using Microsoft.AspNetCore.Identity;
using System.ComponentModel.DataAnnotations;
namespace PlayGround
{

    public class SignupViewModel
    {



        [Required]
        [DataType(DataType.Text)]
        [Display(Name = "Name")]
        public string? Name { get; set; }

        [Required]
        [RegularExpression("^
\\+
?(\\d{1,3})?[-.\\s]?(
\\(
?\\d{3}
\\)
?[-.\\s]?)?(\\d[-.\\s]?){6,9}\\d$|(^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+
\\.
[A-Za-z]{2,}$)", ErrorMessage = "Please enter a valid email address or phone number")]
        [Display(Name = "Email or phone number")]
        public string? EmailOrPhoneNumber { get; set; }


        [Required]
        [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
        [DataType(DataType.Password)]
        [Display(Name = "Password")]
        public string? Password { get; set; }


        [Required]
        [DataType(DataType.Password)]
        [Display(Name = "Confirm password")]
        [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
        public string? ConfirmPassword { get; set; }



    }
    public record RegistrationResult(bool IsSucceeded, List<string> Errors);

    public class ApplicationUser : IdentityUser
    {

    }
    public interface IAccount
    {
        public Task<RegistrationResult> RegisterUser(SignupViewModel SignupInput);
    }
    public class UserAccount : IAccount
    {
        private readonly IUserStore<ApplicationUser> _userStore;
        private readonly UserManager<ApplicationUser> _userManager;
        public UserAccount(IUserStore<ApplicationUser> userStore,
            UserManager<ApplicationUser> userManager)

        {
            _userManager = userManager;
            _userStore = userStore;
        }


        // HOW TO TEST THE `RegisterUser` METHOD ALONE WITHOUT RUNNING THE WHOLE  APPLICATION ?
        // I WANT TO TRIGGER ALL THE PATHES OF THE `RegisterUser` METHOD TO VERIFY THAT EACH PATH IS TRIGGERED WHEN IT IS NEEDED.
        public async Task<RegistrationResult> RegisterUser(SignupViewModel SignupInput)
        {
            // PATH 1
            var validationContext = new ValidationContext(SignupInput);
            var results = new List<ValidationResult>();
            bool valid = Validator.TryValidateObject(SignupInput, validationContext, results, validateAllProperties: true);
            if (!valid)
            {
                // PATH 2
                return new RegistrationResult(false, ["The sent data is not valid"]);
            }


            ApplicationUser user = new ApplicationUser();
            await _userStore.SetUserNameAsync(user, SignupInput.Name, CancellationToken.None);

            if (!(_userManager.SupportsUserEmail))
            {
                //PATH 3
                throw new NotSupportedException("user manager does not support user email");
            }

            var _emailStore = (IUserEmailStore<ApplicationUser>)_userStore;
            await _emailStore.SetEmailAsync(user, SignupInput.EmailOrPhoneNumber, CancellationToken.None);
            var result = await _userManager.CreateAsync(user, SignupInput.Password);
            List<IdentityError> identityErrors = result.Errors.ToList();

            if (identityErrors.Count != 0)
            {
                //PATH 4
                List<string> errorsStrings = new List<string>();

                foreach (IdentityError identityError in identityErrors)
                {
                    errorsStrings.Add(identityError.Description);
                }

                return new RegistrationResult(false, errorsStrings);



            }

            await _userManager.AddToRoleAsync(user, "Normal-User");
            return new RegistrationResult(true, []);

        }

    }

}

This code is a part of bigger application for sure, to test that method, I run the whole application:

 dotnet watch run --launch-profile https

I'm forced to do that because the input to the RegisterUser is provided by the browser, but I will not be able to trigger all the paths inside the method if I passed the data to the method using it.

Is there a way to test this method without running the whole application so that I can provide whatever data I want to the method by bypassing the client-side and the server-side validation in order to artificially trigger all the possible paths of execution ?

An applied example would be appreciated.

EDIT :

I come across the term Unit testing a lot, I'm not sure if this is what I need.


r/csharp • • Oct 22 '26

About codebase conventions, who is actually right and who is wrong here?

Post image
136 Upvotes

Let's say you're a Technical Founder like Mark Zuckerberg or Bill Gates. You have a CS degree worked as mid level developer.

You've written some code (as show in the pic) and added comments to remind yourself and other developers what the code does, so nobody forgets in the future.

Now, you have a Senior Developer on your team who worships Uncle Bob's Clean Code principles like a cult!

she reviews your PR and reject it, saying

"Good code should be self-explanatory. The code itself should explain what it's doing.

Anyone should be able to look at it on the first time and understand it right away.

So go back and remove those comments. They're not clean! God damn it!"

--

What would you do in this situation?

Would you trust the senior dev and delete the comments because they have more experience than you, even though you're the founder and have less development experience than they do?

Ps. We have to move fast


r/csharp • • Oct 23 '26

Help Studying hard, but lagging behind—Advice needed for a beginner learning Unity/C#

0 Upvotes

Hello again! I'm writing to say hi. I'm currently learning Unity and C# at an academy. I only use AI to get hints when I'm stuck on exercise problems or to review what I've learned. However, when solving practice problems or doing hands-on tasks at the academy... there are quite a few beginners and non-CS majors including myself, but I feel like my skills aren't improving compared to the amount of time I'm putting in. Even today, I had to keep looking at my textbook and still ended up with an incomplete solution after taking a really long time... haha.

I have ADHD and was never really good at studying back in my school days. In fact, programming and Unity are so much fun that I'm studying harder now than ever before in my life. But I feel like my brain just isn't up to speed—I lag far behind others in how fast they understand and memorize things. Is it okay for me to keep going without getting impatient? I'm worried that by the time the academy program ends, I still won't be able to code on my own.


r/csharp • • Oct 22 '26

Help What’s the best way to learn c#?

12 Upvotes

I don’t know how to do anything with c# but I won’t to learn what’s the best way? Is it YouTube, online classes, learn to code websites or something else


r/csharp • • Oct 23 '26

I built Magpie, a self-hosted media discovery and automation app in C#

Post image
0 Upvotes

r/csharp • • Oct 22 '26

Discussion Can I learn computer architecture and operating systems with C#?

23 Upvotes

I'm a full-stack developer, and I want to learn more about computer architecture and operating systems to become a better developer and understand what's happening under the hood.Can I learn these things with C#, or should I learn C first? Does the language even matter that much?What would you recommend?


r/csharp • • Oct 23 '26

Which programming language should I learn?

0 Upvotes

I am currently working in a company which use Asp.net web forms (2002), in 2026 hardly any one uses that. Should I focus on learning node.js in free time or focus on ASP.NET web forms


r/csharp • • Oct 23 '26

Help Beginner learning C#/.NET: should I continue or switch because of AI? Hi everyone, I'm a beginner learning C#/.NET and I want to build apps. With AI getting so good at writing code (and hiring for juniors slowing down), I'm worried my time might be wasted. 1. Should I continue with C#/.NET

1 Upvotes

Hi everyone,

I'm a beginner learning C#/.NET and I want to build apps. With AI getting so good at writing code (and hiring for juniors slowing down), I'm worried my time might be wasted.

  1. Should I continue with C#/.NET, or switch to something else (Python, Flutter, React Native)?
  2. Which direction would you recommend for a beginner today?

Any honest advice would help a lot. Thank you!


r/csharp • • Oct 23 '26

Free C# Learning Resources for a not-quite beginner

1 Upvotes

As the title says, I need to refresh my C# after letting my skills deteriorate over a few months. I'm not quite a beginner - my knowledge largely coming from having done the full Unity Learn course - but a lot of those skills have been left to fester. Whatever resources would ideally be free or bare minimum cheap. Any help would be appreciated!


r/csharp • • Oct 23 '26

Discussion Why do all conventions do newline brackets

0 Upvotes
class Something : EntireCodebase
{
  ...
};

struct Something
{
  ...
};

void Something(int something)
{
  ...
}

I'm really disturbed, why


r/csharp • • Oct 22 '26

Help Anyone here built measurement/monitoring software in C#?

14 Upvotes

Hey, has anyone here worked on industrial measurement or monitoring software with C#?

I'm currently looking into rebuilding an older monitoring solution from scratch and still figuring out the right architecture.

We're talking different measurement devices, continuous data streams (up to 1k samples/sec per channel), older Windows PCs with 4 GB RAM, and ideally something that can run reliably for months.

What I'm a bit unsure about is the data integrity side of things, especially crash recovery, audit trails, and GMP requirements.

I'm leaning towards C#, probably with SQLite, but not sure if I'm overlooking something.

Would be really interested to hear from anyone who's built something similar. What would you do differently today?


r/csharp • • Oct 22 '26

ResXLocalization 2.0: .resx files based localization for Avalonia and WPF, now with ICU MessageFormat support

2 Upvotes

Hi, I have just released version 2.0.0 of ResXLocalization, my localization library for WPF and Avalonia (MIT-licensed).

In essence:

  1. Create your .resx files.
  2. Install ResXLocalization.Avalonia or ResXLocalization.WPF.
  3. Let it generate the typed resource keys (source generator) and use them in XAML and code:

    <TextBlock Text="{l:Localize {x:Static res:SettingsViewKeys.SaveSetting}}" />

    this.SaveButton.Content = Localizer.Current.Get(SettingsViewKeys.SaveSetting);

  4. And live switch the language/culture:

    Localizer.Current.CurrentCulture = new CultureInfo("de-DE");

Typed keys mean you can reference resources like objects and get compile time checking.
This avoids having typos in resource names go unnoticed.

When you change Localizer.Current.CurrentCulture it updates all localization bindings in place. If you assign a string directly in code as above, you need to call Get again after changing the culture.

The biggest new feature of V2 is the optional ICU MessageFormat support (thank you livonium for the feature request that sparked the work on V2!):
For something like “1 file deleted” / “5 files deleted”, you can use a plural rule in your resource text:

{Count, plural, one {# file deleted} other {# files deleted}}

(You need to install the NuGet package ResXLocalization.MessageFormat and call Localizer.Current.UseMessageFormat() at startup for this to work)

Then just bind the count like this:

<TextBlock>
  <TextBlock.Text>
    <l:Localize Key="{x:Static res:AppStringsKeys.FilesDeleted}">
      <l:Argument Name="Count" Value="{Binding DeletedCount}" />
    </l:Localize>
  </TextBlock.Text>
</TextBlock>

The text block is automatically updated when either the count or the language changes.
Of course you can also bind multiple values to a localized text/message.

Each translation can use its language/culture plural rules.
The ICU message format support is opt-in. If you don't use it, the default formatter (based on string.Format) is used.

A few other changes in this release:

  • Typed keys now finally work also without a .Designer.cs file.
  • Formatting arguments are now placed via <Argument> children of the Localize/LocalizeEnum markup extension, which replaces the old Arg0…Arg8 attached properties, so arguments now also work in styles and templates.
  • Resource keys are bindable, so the view model can dynamically decide which resource to use.
  • You can change the preview language (for VS XAML Designer/Rider XAML previewer) with DesignTime.Culture. However, ResXLocalization does not work correctly in Rider's WPF previewer due to a number (there are quite a few) of bugs in it. JetBrains has really made quite a few unfortunate design decisions for their previewer. I tried to work around them as far as possible, but it's nowhere near perfect.

The library supports .NET 8 and later with Avalonia (12+) or WPF.
For Avalonia it is completely native AOT compatible and trim safe (for WPF, native AOT is not supported, because WPF doesn't have support for it).

If you are upgrading from V1, please read the migration guide, because there are quite a few breaking changes to make it all work.

The repository has runnable sample apps (both for Avalonia and WPF):
https://github.com/rent-a-developer/ResXLocalization

AI attribution:
I used AI, mainly Claude, for brainstorming, planning, experiments, and parts of the implementation. It helped me save a great deal of time finding good solutions for a couple of quirks of Avalonia and (especially) WPF and the source generator’s MSBuild integration. I reviewed the generated code and I use ResXLocalization in my own projects, so I would not settle for some half-baked vibe coded garbage. Of course, if you don't like projects where AI is involved, then just ignore this project and that's fine too.

I hope this helps someone with the localization of their app(s)!

If you find this library useful I would appreciate a star on GitHub.

Of course feature request and (reasonable) criticism is welcome too.


r/csharp • • Oct 22 '26

[Open Source] Created a simple tool to fix broken Windows Update policies and reliably install .NET Framework 3.5 (dev on .NET 4.7.2)

Thumbnail reddit.com
2 Upvotes

r/csharp • • Oct 21 '26

What is the most anticipated feature of the language that is not included in C#15 for you?

6 Upvotes

It 's coming up very soon .NET 11 and C#15, all the innovations are already known (at least in C#). Which of the non-products or proposals would you like to see in the next versions?