lundi 9 janvier 2017

Property info's GetAccessors method returning IsVirtual for non-virtual property

I have this class:

public class Model : IModel
{
    public int Id {get; set;}
}

public interface IModel
{
    int Id {get; }
}

I get the property info as follows:

var properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
var property = properties[0];

var isVirtual = property.GetAccessors()[0].IsVirtual;

isVirtual is true. Why does happen even though the property is not explicitly marked as virtual?





Aucun commentaire:

Enregistrer un commentaire