[CSHARP]using System; using System.Windows.Forms;
namespace stringApplications { public partial class Form1 : Form { public Form1() { InitializeComponent(); } System.Globalization.StringInfo obj = new System.Globalization.StringInfo("http://softafzar.net"); private void Form1_Load(object sender, EventArgs e) { this.Text = "http://softafzar.net"; txt_setStr.Text = this.Text; }
private void btn_getLength_Click(object sender, EventArgs e)
{
int length;
length = obj.LengthInTextElements;
MessageBox.Show("the length of text element is " + Convert.ToInt16(length));
}
private void btn_getstr_Click(object sender, EventArgs e)
{
string str;
str = obj.String;
MessageBox.Show("the string is " + str);
}
private void btn_setStr_Click(object sender, EventArgs e)
{
string str;
str = txt_setStr.Text;
obj.String = str;
MessageBox.Show("the string is set to " + str);
}
private void btn_substring_Click(object sender, EventArgs e)
{
int startingIndex;
int count;
string str;
startingIndex = Convert.ToInt16(txt_startIndex.Text);
count = Convert.ToInt16(txt_count.Text);
str = obj.SubstringByTextElements(startingIndex, count);
MessageBox.Show("the substring is " + str);
}
}
} [/CSHARP]