Tuesday, January 19, 2016

A sample of using Copy HTML Markup by Productivity Power Tools 2015

class Reflection
{
    static void Main(string[] args)
    {
 
        Assembly executingAssembly = Assembly.GetExecutingAssembly();
 
        Type EmployeeType = executingAssembly.GetType("CSharp.Employee");
        object EmployeeInstance = Activator.CreateInstance(EmployeeType);
        MethodInfo getFullNameMethod = EmployeeType.GetMethod("GetFullName");
 
        string[] parameters = { "Jason""Kong" };
 
        string fullName = (string)getFullNameMethod.Invoke(EmployeeInstance, parameters);
 
        //Employee c = new Employee();
        //string fullName = c.GetFullName("Jason", "Kong");
        Console.WriteLine("The full name is {0}", fullName);
    }
 
}
 
public class Employee
{
    public string GetFullName(string FirstName, string LastName)
    {
        return FirstName + " " + LastName;
    }
}

Reference:Productivity Power Tools 2015

No comments:

Post a Comment