Coupling properties with friendly names
Hey, For some time I've been looking for a good way to couple between the property, and it's display name. Some may say it's a bad practice, but I think sometimes it has it's advantages. So I solved it using DescriptionAttribute. The class is in System.dll, so we don't need to add any reference. Let's take a look on the following class: public class UserChecklistEntity { public bool TakeTheTour { get; set; } public int VisitsCount { get; set; } } Let's decorate the properties with DescriptionAttributes: public class UserChecklistEntity { [Description("Take the tour")] public bool TakeTheTour { get; set; } [Description("Visits count")] public int VisitsCount { get; set; } } And now for the interesting part, add this extension method: public static class ObjectExtensions { public static string GetDescription<T>(this T obj, Expression<Func<T, object>> expression) where T : class { ...