mardi 3 novembre 2015

Get the original property name from a method parameter

How can I get the name of the original property name which is passed as a parameter to a method?

class TestA
    {
        public string Foo { get; set; }

        public TestA()
        {
            Foo = "Bar";

            TestB.RegisterString(Foo);
        }
    }

    class TestB
    {
        public static void RegisterString(string inputString)
        {
            // Here I want to receive the property name that was used
            // to assign the parameter input string
            // I want to get the property name "Foo"
        }
    }





Aucun commentaire:

Enregistrer un commentaire