How to do this 3 operations from PHP in C# (mostly introspection)

krystiandorn

New Member
1st Question:In PHP there is:\[code\]$b = new SomeClass();$a = "foo";$b->$a("something"); // This is the same as $b->foo("something");\[/code\]How do you do this in C#?2nd Question:In PHP I can iterate through each method on a class, similar to:\[code\]$a = new SomeClass(); // Which implements methodA, methodB;foreach($method in get_class_methods(SomeClass())){ $method("do stuff with each method");}\[/code\]How to do this in C#?3rd QuestionPHP has a magic method \[code\]__call()\[/code\] if a Class does not implement a method it executes it as a default such as if a method doesn't exist it still can run\[code\]class NewClass(){// constructor__call(class name, array of parameters){}}\[/code\]so if you do\[code\]$a = new NewClass();$a->thisDoesntExistButWorks("123","abc");// The method gets "magically created" such asthisDoesntExistButWorks(array with 123 and abc)....\[/code\]
 
Back
Top