jeudi 17 février 2022

How do I get property name with class name without creating new obj like GetName(MyClass.Name) = "MyClass.Name"

Cant understand how simple do it

public class MyClass
{
    public string FName;
    public double DoSumma;
}

I wish simple Method like this

public string GetName(...)
{
 return ...
}
...
string propertyname = GetName(MyClass.DoSumma);
// propertyname = "MyClass.DoSumma"
...

I know about

$"{nameof(MyClass)}.{nameof(MyClass.DoSumma)}"

Help?





Aucun commentaire:

Enregistrer un commentaire