mardi 4 juin 2019

Passing a Property to a method and setting it inside that method

I have a class for example:

public class MyClass
{
    public string Name { get; set; }
    public string LastName { get; set; }
    public int SomethingElse { get; set; }
}

Then I want to have a method to be able to call it with arguments as such:

private void KeepingItDRY(MyClass myClass, string valueToSet, ????? PropertyNameToSetItOn)
{
    // some stuff 
    myClass.PropertyNameToSetItOn = valueToSet;
}

But I am not sure how to achieve that?





Aucun commentaire:

Enregistrer un commentaire