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); } }
|
No responses found. Be the first to respond and make money from revenue sharing program.
|