Let's say I have this method that gets string as a extension parameter:
private static List<string> ValidationErrors = new List<string>();
private static void ErrorCheck<T>(this string str)
{
if (string.IsNullOrEmpty(str))
{
// This just returns "str"
// Instead of property name (see "How I use" section")
ValidationErrors.Add(typeof(T).Namespace + "[" + nameof(str) + "]");
}
}
And this is how I use it:
Car.Color.ErrorCheck<Car>();
Where Car object's Color is just string property. So what I want is to get "Color" instead of "str" in my extension method.
Any ideas how I could achieve this?