Dec 25, 2013

How To Check A Input String Is Numeric Or Not in C#

The Easiest Way To Check Weather The Input String Is Numeric or Not Is By Converting It To A Double Variable.For This We can Use  double.TryParse method.This Method Returns A Boolean Value According To the Conversion.





You Can Use Following Code Unit Check the User Input

using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

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

        private void btnCheck_Click(object sender, EventArgs e)
        {
            double dNum1;//To Save The Inputs
            bool chk = double.TryParse(txtEnterText.Text, out dNum1);
            if (chk)
            {
                lblOutPut.Text = "Its A Numeric String";
            }
            else
            {
                lblOutPut.Text = "Its Not A Numeric String";
            }
        }
    }
}

No comments:

JWT Token Decode Using Jquery

When it come to authentication we use many mechanism. Ones the user authenticated we must keep these details somewhere safe. So we can share...