how we can add the two number
sir how we can add the two number if user input the character with digit and truncate the char and take the digit from both input.and print the result after eliminate char from input value
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Apr 8, 2013, 3:49 AM
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text.RegularExpressions;
namespace WebApplication18
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
TextBox2.Text = Regex.Replace(TextBox1.Text, "[^0-9]", "");
TextBox4.Text = Regex.Replace(TextBox3.Text, "[^0-9]", "");
Response.Write(Convert.ToDouble(TextBox2.Text) + Convert.ToDouble(TextBox4.Text));
}
protected void Page_Load(object sender, EventArgs e)
{
TextBox2.Visible = false;
TextBox4.Visible = false;
}
}
}
Pankaj RawatPosted Apr 8, 2013, 3:48 AM
add a namespace
using System.Text.RegularExpressions;
and on button click
Protected Void BtnAdd_Click(Object sender,EventArgs e)
{
string str1=txtstr1.Text;
string str2=txtstr2.Text;
int First_Value=Convert.ToInt32(Regex.Replace(str1, "[^0-9]", ""));
int Second_Value=Convert.ToInt32(Regex.Replace(str2, "[^0-9]", ""));
int Result=First_Value+Second_Value;
}