If you want the name of the setting, then you are looking to get the property name. In the book Metaprogramming in .NET, Kevin Hazzard has a routine that looks something like this:
/// <summary>
/// Gets a property name string from a lambda expression to avoid the need
/// to hard-code the property name in tests.
/// </summary>
public static string GetPropertyName<T>(Expression<Func<T>> expression)
{
MemberExpression body = (MemberExpression)expression.Body;
return body.Member.Name;
}
To call it you would do this:
string propertyName = GetPropertyName(() => Myproject.Properties.Settings.Default.mycolor);
I've added a static reflection utility to some of my projects to allow for access to this and other tools.
EDIT
With July 20, 2015 being set as the RTM date for Visual Studio 2015 and .NET 4.6, this seems like a good time for an update.
Happily, all of my above code goes away in C# 6 (.NET 4.6) since there is a new nameof expression that takes care of this very easily now:
string propertyName = nameof(Myproject.Properties.Settings.Default.mycolor);
Some of the new features are described on the MSDN blog.