I have a string that gets input like say: abcde
.
I then want to take that string and do the following:
- Make the string uppercase
- Parse the string to get each character one by one
- Add a prefix to that new string (prefix is H-I)
- Return a list of every new string in order.
So using abcde
the resulting list should be:
// new list items being returned
H-IA
H-IB
H-IC
H-ID
H-IE
I know there should be an easy way to do this with Linq
but don't quite have it yet.
CodePudding user response:
In a line
var list = str.ToUpper().ToArray().Select(c => "H-1" c).ToList();