I\'d like to enumerate a string
and instead of it returning chars
I\'d like to have the iterative variable be of type string
. This pro
Create an extension method:
public static IEnumerable GetCharsAsStrings(this string value)
{
return value.Select(c =>
{
//not good at all, but also a working variant
//return string.Concat(c);
return c.ToString();
});
}
and loop through strings:
string s = "123456";
foreach (string c in s.GetCharsAsStrings())
{
//...
}