Monday, February 27, 2017

How to validate a string in C#

using System;
using System.Windows.Forms;

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

        private void button1_Click(object sender, EventArgs e)
        {
            bool isNumeric;
            int i;
            string str = "100";
            isNumeric = int.TryParse(str, out i);
            MessageBox.Show("The value of i is " + i);
        }
    }
}

No comments:

Post a Comment