Steven Giesel 8/21/2023

Expression-bodied members in properties

Read Original

This technical article clarifies a key C# concept: the difference between a property with a getter initializer (`public int A { get; } = ...`) and an expression-bodied property (`public int B => ...`). It demonstrates that the initializer evaluates once at creation, while the expression-bodied member is evaluated on every access, using code examples and lowered IL to illustrate the behavior.

Expression-bodied members in properties

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

No top articles yet