Are C properties actually Methods?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Yes, C# properties are methods under the hood. The compiler transforms each property into one or two methods — get_PropertyName() and set_PropertyName(value) — in the generated IL (Intermediate Language). Properties are syntactic sugar that provides field-like access syntax while executing method logic. This means properties can have side effects, throw exceptions, be virtual, and participate in interfaces, just like regular methods.
Properties Compile to Methods
The C# compiler generates IL equivalent to:
You can verify this with reflection or by examining the IL in a decompiler like ILSpy or dnSpy:
Auto-Properties Also Generate Methods
This compiles to:
The backing field has a name that is invalid in C# (<Price>k__BackingField) so you cannot accidentally reference it in your code.
Properties vs Fields in IL
Field access is a single IL instruction (ldfld/stfld). Property access is a method call (call/callvirt). However, the JIT compiler typically inlines simple property getters and setters, making them as fast as direct field access.
Properties Can Do Things Fields Cannot
Because properties are methods, they support features that fields do not:
None of these are possible with fields:
- Fields cannot compute values
- Fields cannot validate on assignment
- Fields cannot have different get/set accessibility
- Fields cannot be virtual or abstract
Interface Properties Are Method Contracts
When an interface declares a property, it is declaring an abstract method. The implementing class provides the method body through its property accessor.
Reflection Treats Properties and Methods Differently
The .NET type system maintains both the property metadata and the underlying method metadata, so you can interact with either abstraction.
Performance: Properties vs Fields
For simple getters and setters, the JIT compiler inlines the method call, producing the same machine code as direct field access. Complex properties with locking, validation, or logging are not inlined and have real method call overhead.
Common Pitfalls
- Assuming properties are free like fields: Properties are method calls. A property getter that performs database queries, file I/O, or expensive calculations runs that code every time it is accessed. Design guidelines recommend that property getters should be fast and side-effect-free.
- Naming conflicts with generated methods: Since properties generate
get_X()andset_X()methods, you cannot define a method namedget_Name()if you also have a property namedName. The compiler rejects this as a duplicate method definition. - Debugging auto-property backing fields: Auto-property backing fields (
<Name>k__BackingField) appear in debuggers and serializers. Some serializers (likeBinaryFormatter) serialize the backing field name, which can break if you rename the property. - Properties in structs and boxing: Accessing a property on a boxed struct creates a copy. Mutating a property on a struct through an interface reference modifies the copy, not the original, because structs are value types.
- Using properties in tight loops: While the JIT inlines simple properties, virtual properties and properties behind interfaces require indirect calls (
callvirt) that cannot be inlined. In performance-critical loops, this overhead can be measurable.
Summary
- C# properties compile to
get_andset_methods in IL - Auto-properties generate a hidden backing field and accessor methods
- Properties support validation, computation, access modifiers, virtual dispatch, and interfaces — fields do not
- The JIT compiler inlines simple property accessors to match field access performance
- Reflection exposes both the
PropertyInfoand the underlyingMethodInfofor each accessor - Design guidelines recommend keeping property getters fast and free of side effects

