samedi 5 décembre 2020

Why does it get nothing that Getting private Properties? (c#)

public class A{
    public Info m_Info = new Info();
    Main()
    {
        Console.WriteLine(m_Info.Property_Count());
    }
    public class Info{

        protected int i_Id;
        protected string s_Name; 

        public int Property_Count(){
            System.Reflection.PropertyInfo[] data = this.GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);

            foreach(var item in data)
                Console.WriteLine(item.Name);
            return data.Length;
        }
    }
}

I am trying to get private or protected properties~ but data.Length always return 0, sounds like it get nothing, why it?





Aucun commentaire:

Enregistrer un commentaire