C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






String Manipulation - Part3


Posted Date: 14 Aug 2008    Resource Type: Articles    Category: .NET Framework

Posted By: D.Jeya kumar(JK)       Member Level: Diamond
Rating:     Points: 10



To remove specified number of characters from string:

If we want to remove some characters from a string we can remove using Remove function. It will have 2 parameters. First parameter is from where we need to remove and the second parameter is how many characters we need to remove. 2nd parameter is optional

Example:

It will remove 1 to 3 chars “ext” will be removed

string strremove = "Text to remove";
string stremovedtext = strremove.Remove(1, 3);
MessageBox.Show(stremovedtext);

To find a string with in a string:

To check whether a string is with in a string or not. We can use contains to check the speacified string is contains in another string.

Example:

Here we are searching “will” is contained in a text


//to find a text with in a text
string strfind="Text with in myself will be searched";
if (stremovedtext.Contains("will") == true)
{
MessageBox.Show("String found");
}
else
{
MessageBox.Show("String not found");
}

To check the beginning or end of a string

If we want to check the beginning or ending of a string. We can check it by using StartsWith or EndsWith.

Example

Here we want to check the string starts with “text” or ends with “text”


string strstartsorends="Text with in myself will be searched";
if ((strstartsorends.StartsWith("text")) || (strstartsorends.EndsWith("text")))
{
MessageBox.Show("It is started or ended with text");
}
else
{
MessageBox.Show("It is not started or ended with text");
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
String Manipulation  .  String  .  Manipulation of String  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: String Manipulaton to find the position of char
Previous Resource: String Manipulation - Part 4
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it support

Contact Us    Privacy Policy    Terms Of Use