Dec 25, 2013

Add Two Numbers And Print The Output in C#


This Simple Program Can Use To Add Two User Inputs and Print The Total.
This Program Also Validate Weather User Inputs Are Numeric To Add, If Not It Will gives A error Message.


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

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

        private void btnAdd_Click(object sender, EventArgs e)
        {
            double dNum1,dNum2;
            bool chk1 = double.TryParse(txtNum1.Text, out dNum1);
            bool chk2 = double.TryParse(txtNum2.Text, out dNum2);
            if (!chk1)
            {
                txtNum1.Clear();
                txtNum1.Focus();
                lblOutPut.Text = "Number Is Not In Correct Format";
            }
            else if (!chk2)
            {
                txtNum2.Clear();
                txtNum2.Focus();
                lblOutPut.Text = "Number Is Not In Correct Format";
            }
            else
            {
                lblOutPut.Text = "Addition Is :"+(dNum1+dNum2).ToString();
            }
        }
    }
}

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...