C# Reflection: How to get class reference from string? -


I want to do it in C #, but I do not know how:

String with name -eg: FooClass and I want to apply a static method to this class:

  FooClass.MyMethod ();  

Obviously, I have to find references to class through reflection, but how?

You would like to use the method.

Here's a very simple example:

  using the system; Using the system. Class program {static zero main () {Type T = type. Gettype ("foo"); LegalInfo = T.Get Method ("Bar", Binding Flex. Static | BindingFlag.Public); Method. Invoke (empty, zero); }} Square fu {public static zero times () {Console.WriteLine ("bar"); }}  

I say simple because it is very easy to find a way that is internal to the same assembly. Please see more detailed information about what you will need to know about it. Once you retrieve your example, then shows you how to apply the method.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -