vendredi 28 juin 2019

C# winforms - Reflection, how to get all string variables/properties defined or used in a class, for example: a Form objects class

I was wondering if there is a way to get/set string variables/properties that defined or used in a form object, for example:

//Assume my form has a panel and bunch of winform controls in it, labels, buttons etc...
    public partial class myForm : Form
    {
        public string myString001 { get; set; } = "I'm a string.";
        public string myString002 { get; set; } = "Everyone knows you are a string.";
        public string myString003 = "A string, but without getter and setter. Retro style.";
        public myForm()
        {
            InitializeComponent();
        }

        private void myForm_Load(object sender, EventArgs e)
        {
            MessageBox.Show("Hi guys there is a string here.");
            string str = myClass.myString;
        }

        private void AccessStrings()
        {
            //I have to access all those strings, and of course, the winform controls' string properties too.
            //Also the string properties of custom classes that used in this myForm class.
        }
    }

I don't know if i explained myself good enough, but this is what i wonder. Thanks to all who read, commented this question, have a nice day!





Aucun commentaire:

Enregistrer un commentaire