C# Feature - Partial properties
Partial properties
Section titled “Partial properties”Partial properties allow a property declaration and its implementation to live in different parts of the same partial type.
Introduced In
Section titled “Introduced In”This feature was introduced in C# 13.0 (2024).
Why This Feature Exists
Section titled “Why This Feature Exists”This feature is mainly useful in source-generation and code-generation scenarios, where one file declares the shape of a type and another file supplies the implementation. It reduces boilerplate in generated partial types while keeping declarations and implementations aligned.
When To Use It
Section titled “When To Use It”- Use it in generated-code scenarios where declarations and implementations are intentionally separated.
- Use it in large partial types where generated and handwritten code must coexist cleanly.
- Avoid it in ordinary application code unless the split is genuinely helpful.
Before
Section titled “Before”public partial class CustomerViewModel{ private string _name = "";
public string Name { get => _name; set => _name = value; }}public partial class CustomerViewModel{ public partial string Name { get; set; }}
public partial class CustomerViewModel{ private string _name = "";
public partial string Name { get => _name; set => _name = value; }}Practical Use Case
Section titled “Practical Use Case”One common scenario is a generated partial type that declares bindable or tracked members, while a handwritten partial file defines validation or storage rules.
Common Pitfalls
Section titled “Common Pitfalls”- This is not a general readability improvement for most codebases.
- Keep declaration and implementation naming perfectly synchronized.
- Use it sparingly; partial members are easiest to justify in tooling or generated-code workflows.
Version Notes
Section titled “Version Notes”- C# 13 added partial properties as part of broader partial member enhancements.