This is how you can do:
string str = "ahde7394";
var array = str.ToCharArray();
var letters = array.Where(w => Char.IsLetter(w)).ToList().Select(s => s.ToString()).ToArray();
var numbers = array.Where(w => Char.IsNumber(w)).ToList().Select(s => (int)Char.GetNumericValue(s)).ToArray();
//new strings:
string newLetter = string.Join("", letters.ToArray());
int newNumbers = numbers.Aggregate((i, j) => int.Parse(i.ToString() + j.ToString())); //to get real number
Mitja
No comments:
Post a Comment