Notifications
Article
EXPRESSION-BODIED MEMBERS
Updated 4 months ago
34
0
They are pretty cool
Expression bodies allow you to make auto properties and also set them on the same line. By creating an expression body ou provide a very readable way to view members.
An expression-bodied method consists of a single expression that returns a value whose type matches the method's return type.
Ever since I started using Expression Bodies I can't stop. So I hope by showing you ways you can use it you will join me in using them as well. Expression bodies are a c# 6 language feature. So you need at least .NET 4.6 to use. To start using it in Unity today follow these simple steps.
The below code returns the string “Donray Williams” when you access the property “New Name”




Expressions for methods/functions which returns value to the caller
For example, the below code will return sub of the parameters when you call the “NewSum” method



My own implementations in recent projects

Tags:
Donray Williams
Game Programmer - Programmer
2
Comments