I'm trying to learn reflection
in c#, and while learning I'm getting this exception.
'System.ArgumentNullException' occurred in mscorlib.dll error
How do I resolve this error?
class Program
{
static void Main(string[] args)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
Type customerType = executingAssembly.GetType("Reflection.Customer");
object customerInstance = Activator.CreateInstance(customerType);
MethodInfo GetFullName = customerType.GetMethod("GetFullName");
string[] methodParameter = new string[2];
methodParameter[0] = "Minhaj";
methodParameter[1] = "Patel";
string Full_Name = (string)GetFullName.Invoke(customerInstance, methodParameter);
Console.WriteLine("Full Name = {0}", Full_Name);
Console.ReadKey();
}
}
Customer Class code
class Customer
{
public string GetFullName(string First_Name, string Last_Name)
{
return First_Name + " " + Last_Name;
}
}
Aucun commentaire:
Enregistrer un commentaire