Blue Theme Orange Theme Green Theme Red Theme
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
Search :       Advanced Search »
Home » Blogs Home » Blog Detail

Concatenate integers and string in C#

 by Rohatash Kumar on Oct 31, 2011

Here, we will see how to concatenate integers and string in C#.
Comments: 0 Views: 978 Printable Version 

Here, we will see how to concatenate integers and string in C#. To do that we take two TextBox for integers and one TextBox for string and one TextBox for concatenate both integers and string.

Aspx code

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="add.aspx.cs" Inherits="addtextbox.add" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

        First:

        <asp:TextBox ID="txt1" runat="server"></asp:TextBox>

        <br />

        <br />

        Second:<asp:TextBox ID="txt2" runat="server"></asp:TextBox>

        <br />

        <br />

        Third<asp:TextBox ID="txt3" runat="server"></asp:TextBox>

        <br />

        <br />

        <asp:Button ID="Button1" runat="server" onclick="Button1_Click"

            style="margin-bottom: 0px" Text="Button" />

        <br />

        <br />

        Fourth:<asp:TextBox ID="txt4" runat="server"></asp:TextBox>

        </div>

    </form>

</body>

</html>

The form looks like below figure1.

figure1.gif

Figure1

Now double click on the Button control and add the following code.

protected void Button1_Click(object sender, EventArgs e)

        {

          int a  =Convert.ToInt32(txt1.Text) ;          

           int b= Convert.ToInt32(txt2.Text);

           string c = txt3.Text;

           txt4.Text = a.ToString() + b.ToString() + c;

        }

Now run the application and test it.

figure2.gif

Figure2

Now click on the Button to Concatenate integers and string.

figure3.gif

Figure3

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
 
What do you say about this post? Post a comment here
*Title:
*Comment:
 
Comments not available.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor

 Blogger's Profile
Age: Not Available
Location:
Title: Developer
Joined: Aug 10, 2010
Education: Masters Degree
 More Blogs from this Blogger
No record available
 Latest Blogs
[Video] OnClose Handler
[Video] Storing and Loading the Window and Toolbar position
The Euclidean Algorithm
Swapping Exe Process
How Exe file is Generated by VS2005 C++ Project?
What is Exe
Header files: Multiple Inclusion problem - Solution B
Header files: Multiple Inclusion problem - Solution A
Header files: Multiple Inclusion problem - Reason
Header files: Multiple Inclusion problem
View all »
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 
6 Months Free & No Setup Fees ASP.NET Hosting!
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.