Skip to content

Instantly share code, notes, and snippets.

MNF / PropertyNameExtension.cs
Last active Dec 15, 2015 — forked from StevePy/PropertyNameExtension.cs
Added Converted to MS Test from NUnit PropertyNameUnitTests
View PropertyNameExtension.cs
using System;
using System.Linq.Expressions;
public static class PropertyNameExtensions
/// <summary>
/// Extension method for exposing the name of properties without resorting to
/// magic strings.
/// Use: objectReference.PropertyName( x => x.{property} ) to retrieve the name.
/// I.e. objectReference.PropertyName( x => x.IsActive ); //will return "IsActive".