c# - Read properties of derived as well as base class -


i have 2 classes

class 1

public class baseclass {    public string prop1{get;set;}    public string prop2{get;set;}    public string prop3{get;set;} } 

class 2

public class derived:baseclass {     public string prop4{get;set;} } 

now when try read properties following code, obvious returns derived class's properties

propertydescriptorcollection properties = typedescriptor.getproperties(typeof(derived)); 

is there way can read properties of derived baseclass

why not use reflection?

  propertyinfo[] properties = typeof(derived).getproperties(bindingflags.public | bindingflags.instance);    console.write(string.join(envrironment.newline, properties.select(p => p.name))); 

Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -