this post was submitted on 01 Feb 2026
13 points (100.0% liked)

C Sharp

1777 readers
1 users here now

A community about the C# programming language

Getting started

Useful resources

IDEs and code editors

Tools

Rules

Related communities

founded 2 years ago
MODERATORS
top 7 comments
sorted by: hot top controversial new old
[–] Kissaki@programming.dev 2 points 2 days ago

Like them.

They have their downsides, so they're no more than an alternative to other approaches. They can condense code and concerns in some cases. The more complex the type is, the less obvious the primary constructor parameters become.

[–] dan@upvote.au 11 points 1 month ago* (last edited 1 month ago) (1 children)

The main issue I have with them for classes is that there's no way to mark the parameters as readonly.

[–] marlowe221@lemmy.world 2 points 1 month ago

I think that’s one of the reasons I like primary constructors - when you see one, it’s a signal that there’s nothing “special” happening with the parameters.

On the other hand… there are like 7 different ways to do constructors at this point (exaggerating a little…) and it’s a lot to keep track of.

[–] labsin@sh.itjust.works 5 points 1 month ago (2 children)

I think they especially make sense for records so you can easily create shallow modifyable value semantic types with little boilerplate code.

I do hate that all these features are yet more keywords and weird syntax. It's becoming C##.

Like the records are just sytesized methods on classes or structs. We already have this in the language with source generation. If something there was missing to create records, it would IMO make more sense to improve the source generation so the community also has access to the ecmxtensions. And the record could be split up in it's separate features (copy constructor, defaul ToString imp, equatable) so we could choose to use part of it.

[–] Kissaki@programming.dev 1 points 2 days ago

I do hate that all these features are yet more keywords and weird syntax. It’s becoming C##.

It's called sharp because you can cut yourself. /s

[–] marlowe221@lemmy.world 2 points 1 month ago

Regarding your point about C##…

It does seem like, in their effort to make the language less Java-y/enterprise-y, we now have multiple syntaxes for everything. I get the desire to maintain backwards compatibility but it does start to make the available range of syntax feel kind of messy.

[–] JakenVeina@midwest.social 2 points 1 month ago

Me personally? Hate 'em. In every scenario. They force you to break standard naming semantics.