c# - How do I call a method on a static class if I've only got the classes string name? -
for example have list of strings happen names of static classes , depending on string name selected want use static class. know method called on static class, , same on each class.
if strings "x", "y", "z" , selected string "z" , method called process()
, in code call x.process()
in way, x being name of actual static class.
remember these static
classes.
you use reflection include namespace
class
name.
type type = type.gettype("namespace.x"); methodinfo process = type.getmethod("process"); process.invoke(null, null);
Comments
Post a Comment