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 Manipulaton to find the position of char


Posted Date: 14 Aug 2008    Resource Type: Articles    Category: .NET Framework
Author: D.Jeya kumar(JK)Member Level: Diamond    
Rating: Points: 10



To find the first Position of a char

Indexof will find the position of the character with in a string.if we want to find a Character with in a string we can use Indexof().


Example

string strrfind = "My nick name is jk";
int intchar = strrfind.IndexOf("n");
MessageBox.Show(intchar.ToString());



IndexofAny

IndexofAny will find the position of the character with in a string of any character in a specified array of unicode characters.



Example

string strrfind = "My nick name is jk";
char[] test ={ 'n'};
int intchar = strrfind.IndexOfAny(test,5);
MessageBox.Show(intchar.ToString());




To replace a string in a string

To find a string or character in a string and replace the string with another string. It will replace the old char or string with new char or string to all occurrences.



Example

string strreplace = " My changed nick name is jk";
MessageBox.Show(strreplace.Replace("jk","JEY"));




Split Function

Split function is to split a string with the specified character.It will return the string array that are delimted by the specified character.



Example

string strsplit = " Here is a message for the Dot net developers. I am splited into two text now.I am the next text";
//Split shar
char [] csplitchar={'.'};
string [] strsplitcvalues;
//Splited values in a array
strsplitcvalues = strsplit.Split(csplitchar);

//To display the array
foreach(string s in strsplitcvalues )
{
MessageBox.Show ("The spliter string is " + s);
}



continued...




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 Manipulaton  .  String Manipulation  .  Position of Character  .  Character Position  .  

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: Passing only values without parameters for Stored Procedure
Previous Resource: String Manipulation - Part3
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use