Getting set accessor for property in abstract class, not possible?

Posted by Lars Udengaard on Stack Overflow See other posts from Stack Overflow or by Lars Udengaard
Published on 2010-05-17T13:14:08Z Indexed on 2010/05/17 13:20 UTC
Read the original article Hit count: 156

Filed under:
|
|

Given the class':

public abstract class AbstractEntity
{
    public virtual Guid Id { get; private set; }
}

public class Entity
{
    public virtual Guid Id { get; private set; }
}

And a PropertyInfo for the property 'Id'.

When calling the method:

PropertyInfo.GetAccessors()

It returns both the get-method and the set-method when the class is not abstract (Entity), but only the get-method when the class is abstract (AbstractEntity).

Why is this? And is there another way to get the set-method from a property with a private set?

© Stack Overflow or respective owner

Related posts about c#

Related posts about reflection