using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //string[] lbl = { "+", "-", "*", "/" };
            //Button[] btns = new Button[4];
            //for(int i=0;i<btns.Length ;i++)
            //{
            //    btns[i] = new Button();
            //    btns[i].Parent = this;
            //    btns[i].Top  = i *( btns[i].Height + 10)+20;
            //    btns[i].Text = lbl[i];
            //    btns[i].Click += new EventHandler(btn_click);                
            //}
            object[] obj = new Object[3];
            Button b = new Button() { Text = "B1", Top = 10, Left = 10 };
            TextBox t = new TextBox() { Text = "T1", Top = 100, Left = 10 };
            int x = 10;
            obj.SetValue(b, 0);
            obj.SetValue(t, 1);
            obj.SetValue(x, 2);
            for (int i = 0; i < obj.Length; i++)
                if (obj[i].GetType() == typeof(Button))
                    ((Button)obj[i]).Parent = this;
                else
                    if (obj[i].GetType() == typeof(TextBox))
                        ((TextBox)obj[i]).Parent = this;
                    else
                        MessageBox.Show(((int)obj[i]).ToString());

        }
        void btn_click(object sender, EventArgs e)
        {
            //   MessageBox.Show(((Button)sender).Text);
            Button b = (Button)sender;
            MessageBox.Show(b.Text);
        }

        
    }
}
