mardi 26 février 2019

How can I dynamically create instance of a class using reflection and then dynamically connect another method?

 class Country
{
    public string Name { get; set; }
    public int Population { get; set; }


    public Country(string name, int population)
    {
        Name = name;
        Population = population;
    }

    public string GetCountryInfo()
    {
        return "Country " + Name + " has the population of "+ Population +".";
    }

In Main method, I have to dynamically create instance of Country class using reflection. After that, I have to dynamically connect GetCountryInfo method. How do I do these things?





Aucun commentaire:

Enregistrer un commentaire