/// <summary>
        /// 1. Our objective is to be able to print out all the of classes, attributes, methods, etc within this namespace. The way to do this is by using
        /// reflection. Reflection is inspecting an assemblies' (.exe for console application and .dll for web-based) metadata at runtime. A real world
        /// example of this is when you are creating a console application, there is a little properties menu that shows up and displays a buttons'
        /// properties, it is done using this.
        /// </summary>
        public static void Main()
        {
            Type T = Type.GetType("reflection.customer");

            //Type T = typeof(customer);
            Console.WriteLine("Full name = {0}", T.FullName);
            Console.WriteLine("name = {0}", T.Name);
            Console.WriteLine("namespace = {0}", T.Namespace);
            Console.WriteLine();

            Console.WriteLine("Properties:");
            PropertyInfo[] properties = T.GetProperties();
            foreach (PropertyInfo PI in properties)
            {
                Console.WriteLine(PI.PropertyType.Name + " " + PI.Name);
                Console.WriteLine(PI.Attributes);
            }

            Console.WriteLine();
            Console.WriteLine("Methods:");
            MethodInfo[] methods = T.GetMethods();
            foreach (MethodInfo MI in methods)
            {
                Console.WriteLine(MI.ReturnType + " " + MI.Name);
            }

            Console.WriteLine();
            Console.WriteLine("Constructors:");
            ConstructorInfo[] consturctorinfo = T.GetConstructors();
            foreach (ConstructorInfo CI in consturctorinfo)
            {
                Console.WriteLine(CI.ToString());
            }
        }
Exemple #2
0
        private void btnDiscoverTypeInfo_Click(object sender, EventArgs e)
        {
            string TypeName = txtTypeName.Text;
            Type   T        = Type.GetType(TypeName);

            lstMethods.Items.Clear();
            lstProperties.Items.Clear();
            lstConstructors.Items.Clear();

            MethodInfo[] methods = T.GetMethods();
            foreach (MethodInfo MI in methods)
            {
                lstMethods.Items.Add(MI.ReturnType.Name + " " + MI.Name);
            }

            PropertyInfo[] properties = T.GetProperties();
            foreach (PropertyInfo PI in properties)
            {
                lstProperties.Items.Add(PI.PropertyType.Name + " " + PI.Name);
            }

            ConstructorInfo[] constructors = T.GetConstructors();
            foreach (ConstructorInfo CI in constructors)
            {
                lstConstructors.Items.Add(CI.ToString());
            }
        }
        private void Button1_Click(object sender, EventArgs e)
        {
            Init();
            if (bankNamecomboBox.Text == "Sonali")
            {
                interestRate = percent(8);
            }
            else if (bankNamecomboBox.Text == "Brack")
            {
                interestRate = percent(5);
            }
            else if (bankNamecomboBox.Text == "DBBL")
            {
                interestRate = percent(7);
            }
            else if (bankNamecomboBox.Text == "HSBC")
            {
                interestRate = percent(6);
            }

            totalInterest                = balance * year * interestRate;
            totalInterestWithCapital     = balance + totalInterest;
            totalInterestWithCapBox.Text = totalInterestWithCapital.ToString();
            output(totalInterest);

            float CI;
            float q = 1 + interestRate;

            CI = (float)balance * (float)Math.Pow(q, year);
            totalCycleInterest = CI - balance;

            totalCycleInterestBox.Text        = totalCycleInterest.ToString();
            totalCycleInterestWIthCapBox.Text = CI.ToString();
        }