mercredi 13 février 2019

C# - Dynamic Creating and Calling an class using Reflection | Console Application

I have some problems about this section in C# language.

So I'm trying to do something like revealing reflection of this class and it's methods.

class Car
{
    public string Name { get; set; }
    public int Shifts{ get; set; }


    public Car(string name, int shifts)
    {
        Name = name;
        Shifts = shifts;
    }

    public string GetCarInfo()
    {
        return "Car " + Name + " has number of shifts: " + Shifts;
    }

}

So I have this class Car, and this method GetCarInfo(), now, I'm trying to: Dynamically create instance of this class Car, and dynamically calling a method GetCarInfo(), I would like to show result in console, but I can't when I run it it shows build errors. The application break everytime. Thanks on quick responses. Sorry for bad english. Sincerely, xVenum.dll.





Aucun commentaire:

Enregistrer un commentaire