jeudi 13 septembre 2018

Calling class object's function from string in c#

I'm using WPF mvvm pattern anyway if some method got string parameter is this possible calling like

SomeClass1 sc  = new SomeClass();
DummyClass2 dc = new DummyClass2();

public void SomeMethod(string param) //param = "SomeMethodName"
{ 
    sc.'param'(dc);
}

The key is calling class object's fuction via param without branch or Data structure mapping.

maybe using reflection.. any good idea?





Aucun commentaire:

Enregistrer un commentaire