This question already has an answer here:
i have 2 classes like this.
public class A
{
public int Id {get; set;}
public abstract string Type { get; }
}
public class B
{
public override string Type => "value";
}
i need to find the value of property Type in class B. using NET core i try to get the value in this way:
var value = typeof(B).GetProperty("Type").GetValue(typeof(B));
i get this exception:
Object does not match target type.
even passing typeof(A) in GetValue() i keep getting the same error.
Aucun commentaire:
Enregistrer un commentaire