Showing posts with label gettype() in c#. Show all posts
Showing posts with label gettype() in c#. Show all posts

Monday, January 5, 2015

Check Input Type of TextBox



Check  Input Type of TextBox

T o know what is your input type of your textbox , Simply write given below code , on button click

private void button1_Click(object sender, EventArgs e)
        {
            int num = 0;
            double d = 0;
            bool b = false;
            if (int.TryParse(textBox1.Text, out num))
            {
                MessageBox.Show("input is=" + num.GetType());
            }
            else if (double.TryParse(textBox1.Text, out d))
            {
                MessageBox.Show("input is=" + d.GetType());
            }
            else if (Boolean.TryParse(textBox1.Text, out b))
            {
                MessageBox.Show("input is=" + b.GetType());
            }
            else
            {
                MessageBox.Show("input is=" + textBox1.Text.GetType());
            }

        }
You will get the type of input of your textbox.