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 !




Basic string operations


Posted Date: 14 Feb 2004    Resource Type: Articles    Category: .NET Framework

Posted By: Tony John       Member Level: Gold
Rating:     Points: 10




// Declare a string variable and assign the value it it.
string myLine = "dotnetspider.com is the best technology site";

string str;

// extract portion of the string - starting from position 0, get 16 characters.
str = myLine.Substring(0, 16);
Console.WriteLine(str); // Displays : dotnetspider.com

// extract portion of the string - starting from position 17, get 12 characters.
str = myLine.Substring(17, 12);
Console.WriteLine(str); // Displays : is the best

// Split the line into words. Split based on the space ("").
string[] strArray = myLine.Split(' ');
Console.WriteLine("strArray has " + strArray.Length + " words"); // Displays : strArray has 6 words

// Convert all characters to UPPERCASE
str = myLine.ToUpper();
Console.WriteLine(str); // Displays : DOTNETSPIDER.COM IS THE BEST TECHNOLOGY SITE

// Find location of a word in a string
int position = myLine.IndexOf("best");
Console.WriteLine(position); // Displays : 24

// Insert a string into another string in specific position
str = myLine.Insert(20, "one of ");
Console.WriteLine(str); // Displays : dotnetspider.com is one of the best technology site




Responses


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

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

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: Basic string operations
Previous Resource: C# FAQ
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

web conferencing

Contact Us    Privacy Policy    Terms Of Use