Reputation: 45285
I'm just wondering if there is in .Net framework method which returns ASCII chars sequence? Something like:
public static string ascii()
{
return "abcdefghijklmnuopqrstuvwxyz";
}
Upvotes: 1
Views: 375
Reputation: 45071
In fact String
already implements IEnumerable<Char>
, so your code is already you need. But you can make it more specific by changeing the return type:
public IEnumerable<Char> Ascii
{
get
{
return "abcdefghiklmnopqrstuvwxyz";
}
}
If you really like to make it in a more LINQish way you could also write:
public IEnumerable<Char> Ascii2
{
get
{
return Enumerable.Range((int)'a', 26).Select(i => (char)i);
}
}
Upvotes: 2
Reputation: 354366
Uhm, you wrote it there. And no, there is nothing in the framework to do so. Why would there be? This method isn't solving a particular problem and it's downright trivial to write yourself. Note though, that the naming convention would dictate the name Ascii
:-)
Upvotes: 1