Code Snippet posted by:
Anwarbesa@Yahoo.Com | Posted on: 5/2/2012 | Category:
C# Codes | Views: 531 | Status:
[Member] |
Points: 40
|
Alert Moderator
Hi.. this is a code written in c#.net for searching about text from a string
There are four text boxes one for entering a string or text from the user, another for the label addressed as (start with), another for the label addressed as (end with).. and the last one for the result.(Note:you should make the property of text box as multi line)
And there is a button for search.. and now you should click the button and write this code:
string[] sentences = textBox1.Text.Split(' ');
string sPattern1 = textBox2.Text.Trim();
string sPattern2 = textBox3.Text.Trim();
textBox4.Text = "";
foreach (string s in sentences)
{
if (sPattern1.Trim().Length > 0 && s.ToUpper().StartsWith(sPattern1.ToUpper()))
textBox4.Text += s + "\r\n";
if (sPattern2.Trim().Length > 0 && s.ToUpper().EndsWith(sPattern2.ToUpper()))
textBox4.Text += s + "\r\n";
I wish this is will be helpful ^_^
Thanks and regards C is a sea.. and you are the sea of C!
Thanks & Regards