using System.Collections.Generic;
using System.Linq.Expressions;
public class AccountOwner
public string AccountOwnerName { get; set; }
public string AccountOwnerNumber { get; set; }
public double AccountOwnerDouble { get; set; }
public int AccountOwnerInt { get; set; }
static string GetNameOf<T>(Expression<Func<T>> property)
var unary = property.Body as UnaryExpression;
return (unary.Operand as MemberExpression).Member.Name;
return (property.Body as MemberExpression).Member.Name;
static List<string> GetNameOf<T>(IEnumerable<Expression<Func<object>>> properties)
return properties.Select(GetNameOf).ToList();
public static void Main(string[] args)
var x = new AccountOwner();
var listOfPropertyNames = GetNameOf<AccountOwner>(
new Expression<Func<object>>[]
() => x.AccountOwnerName,
() => x.AccountOwnerNumber,
() => x.AccountOwnerDouble,
foreach (var property in listOfPropertyNames)
Console.WriteLine(property);