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 !




Seperate Characters and Numbers in a String in C#


Posted Date: 13 Jun 2008    Resource Type: Code Snippets    Category: String Manipulations

Posted By: srilu       Member Level: Diamond
Rating:     Points: 5



This sample code splits the string into characters and numbers and adds them to seperate arraylists.

char[] num ={ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
char[] chr ={ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
string str = "adasdsad536546QWEQWEQ";
string[] snum = str.Split(num);
string[] schr = str.Split(chr);
IEnumerator enu = snum.GetEnumerator();
IEnumerator en = schr.GetEnumerator();
while (enu.MoveNext())
{
if (Convert.ToString(enu.Current) != "")
{
al.Add(enu.Current);
}
}
while (en.MoveNext())
{
if (Convert.ToString(en.Current) != "")
{
al.Add(en.Current);
}
}




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 manipulations  .  String manipulation  .  Seperate characters and numbers in a string  .  Seperate alphabets and numbers  .  Segregate alphabets and numbers  .  

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: Function to Check a string is upper case or not
Previous Resource: Convert a String to ASCII
Return to Discussion Resource Index
Post New Resource
Category: String Manipulations


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use