Problem description
Assuming you have an interface / class, and wish to get a Property/Func/Action name, how and what is the best practice to do so?
e.g. given:
public interface IConvertible
{
// ...
bool ToBoolean(IFormatProvider provider);
// ...
}
How to get the name of 'ToBoolean' method, in a strongly-typed way?
Also, how to get the property name of IsValueCreated from
Lazy<object>.IsValueCreated
Motivation
When you'll do reflection on an interface [method / property / etc], the compiler will help you find all references to it.
For .Net 5 and above: use nameof (credits to m-kazem-akhgary)
For .Net 4.5v and below:
Resources
Waiting for your input / suggestions / insights...