Property name from lambda expression in C#

preview_player
Показать описание
A common pattern in C# is to pass a property name by using a lambda expression as the parameter. This video shows how to extract that property name from the passed in lambda expression.

The crucial code you need is the following:-

var expression = (MemberExpression)action.Body;
string propertyName = expression.Member.Name;

Effective C# answers common questions about the C# language and the dotnet ecosystem. If you have a programming question about C# or .net then add it as a comment below.

Рекомендации по теме
Комментарии
Автор

very helpful - hoping you'll be making more videos soon

latedeveloper
Автор

Where did you go? Hopefully all is well.

infocyde
Автор

Hey! Can you explain System.Net.Websockets I have some trouble with them but you explain very good everything so can this be your next video?

kuchxr