Today we will discuss two main operation that can be performed with String while developing an application in ASP.NET. First let me explain these two terms. Split is the term in which we break a string value to multiple string values. The splitting is performed with a specific separator value. Suppose we need to split a date like “12-09-2011″. Then in that case the separator values is “-” and after split the string we will save the three different values in different different variables. The another term Merge is the reverse process of Split. Merging the values makes multiple values into a single value. In this article I will discuss these two operation with example.
Free Download: Split and Merge String : Demo Project
Code of Web Page
1. Split a String Value
protected void btngetdate_Click(object sender, EventArgs e)
{
string date = txtDate.Text;
string[] dt = date.Split('-');
txtDay.Text = dt[0];
txtMonth.Text = dt[1];
txtYear.Text = dt[2];
}
2. Merge a String Value
protected void btnMerge_Click(object sender, EventArgs e)
{
txtMergedDate.Text = txtDay.Text + "-" + txtMonth.Text + "-" + txtYear.Text;
}

Yuck.
Note, in Tcl:
split a value:
lassign [ split $txtDate - ] Day Month Year
merge the values (if split as above):
join [ list $Day $Month $Year] -
Alternate split:
set splitdata [ split txtDate - ]
Merge (if split as above)
join $splitdata -