<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/an-introduction-to-primary-constructors-in-c-12-gd7h0oklf" -->

---
title: An introduction to primary constructors in C#12 | daily.dev
description: This post introduces the primary constructors feature in C#12 and discusses its use in reducing duplication in classes. It explains two approaches to use...
canonical: https://daily.dev/posts/an-introduction-to-primary-constructors-in-c-12-gd7h0oklf
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: An introduction to primary constructors in C#12 | daily.dev
og:description: This post introduces the primary constructors feature in C#12 and discusses its use in reducing duplication in classes. It explains two approaches to use...
og:url: https://daily.dev/posts/an-introduction-to-primary-constructors-in-c-12-gd7h0oklf
og:image: https://api.daily.dev/og/posts/gd7H0oKLF.png
og:image:alt: An introduction to primary constructors in C#12
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# An introduction to primary constructors in C#12

**[.NET Escapades](https://daily.dev/sources/andrewlock)** · 7 min read · 42 upvotes · 3 comments

## Summary

This post introduces the primary constructors feature in C#12 and discusses its use in reducing duplication in classes. It explains two approaches to use primary constructors and how they work behind the scenes. The post also mentions the advantages and disadvantages of using primary constructors.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://andrewlock.net/an-introduction-to-primary-constructors-in-csharp-12/>

## Community discussion

Top comments from developers on daily.dev.

**@alexvirlan** · 2 upvotes

> That's kind of cute for small or simple classes.

**@daoudabeye** · 0 upvotes

> Very useful ...

**@stuartgreig** · 0 upvotes

> Primary constructors are one of those things once you've used you can never go back, it's so much cleaner

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 1 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments
- [CNCF Unveils Schedule for KubeCon \+ CloudNativeCon Europe 2026](https://daily.dev/posts/cncf-unveils-schedule-for-kubecon-cloudnativecon-europe-2026-ikhcoa5cb) · CNCF · 2 upvotes · 0 comments
- [CNCF Debuts KubeCon \+ CloudNativeCon Japan 2026 Schedule](https://daily.dev/posts/cncf-debuts-kubecon-cloudnativecon-japan-2026-schedule-xp5pyudub) · CNCF · 1 upvotes · 0 comments

---

Tags: [#c](https://daily.dev/tags/c), [#.net](https://daily.dev/tags/.net), [#c#](https://daily.dev/tags/c#), [#.net-core](https://daily.dev/tags/.net-core)

[View this post on daily.dev](https://daily.dev/posts/an-introduction-to-primary-constructors-in-c-12-gd7h0oklf)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"An introduction to primary constructors in C#12","url":"https://daily.dev/posts/an-introduction-to-primary-constructors-in-c-12-gd7h0oklf","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/an-introduction-to-primary-constructors-in-c-12-gd7h0oklf"},"datePublished":"2024-05-14T10:30:40.794Z","dateModified":"2024-05-14T10:30:38.848Z","description":"This post introduces the primary constructors feature in C#12 and discusses its use in reducing duplication in classes. It explains two approaches to use...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/6d2df7071cf945ed9e163ada6c7124a9?_a=AQAEuiZ","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/6d2df7071cf945ed9e163ada6c7124a9?_a=AQAEuiZ","isAccessibleForFree":true,"articleSection":".NET Escapades","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":".NET Escapades","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/74ebd66cf7e840b6b29913eae3da9189","url":"https://daily.dev/sources/andrewlock"},"commentCount":3,"discussionUrl":"https://daily.dev/posts/an-introduction-to-primary-constructors-in-c-12-gd7h0oklf","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":42},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":3}],"keywords":"c,.net,c#,.net-core","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":".NET Escapades","item":"https://daily.dev/sources/andrewlock"},{"@type":"ListItem","position":3,"name":"An introduction to primary constructors in C#12"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/an-introduction-to-primary-constructors-in-c-12-gd7h0oklf","comment":[{"@type":"Comment","text":"That’s kind of cute for small or simple classes.","datePublished":"2024-05-17T06:58:10.805Z","url":"https://daily.dev/posts/gd7H0oKLF#c-gFbh5gv8E","author":{"@type":"Person","name":"Alex Virlan","url":"https://daily.dev/alexvirlan","image":"https://media.daily.dev/image/upload/s--SNisoF5U--/f_auto/v1715880033/avatars/avatar_npP8DZj9ckba6EHDqlNhq"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"Very useful …","datePublished":"2024-08-10T15:16:19.513Z","url":"https://daily.dev/posts/gd7H0oKLF#c-mFjHjVwVB","author":{"@type":"Person","name":"Daouda Beye","url":"https://daily.dev/daoudabeye","image":"https://lh3.googleusercontent.com/a/ACg8ocL-YfHvjYpkNEDWJGcSure6mvtvWI7JhxGNtoTnPNB9xClEY1Sv=s96-c"}},{"@type":"Comment","text":"Primary constructors are one of those things once you’ve used you can never go back, it’s so much cleaner","datePublished":"2026-03-05T22:34:13.759Z","url":"https://daily.dev/posts/gd7H0oKLF#c-cNUF5enMm","author":{"@type":"Person","name":"Stuart Greig","url":"https://daily.dev/stuartgreig","image":"https://media.daily.dev/image/upload/s--FoVqUWgr--/f_auto/v1772633885/avatars/avatar_V6TOuZS8XXplYvc5hNLgE?_a=BAMAMiiu0"}}]}
```

