Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
プロパティ名の取得
using System.Linq.Expressions;
static class PropertyGet
{
/// <summary>
/// プロパティ名を取得する
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="e"></param>
/// <returns></returns>
public static string GetPropertyName<T>(Expression<Func<T>> e)
{
var memberEx = (MemberExpression)e.Body;
return memberEx.Member.Name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.