我正在尝试枚举C#中的运行时输入,以打印枚举变量的值。例如:
class Program
{
enum Alphabets { a = 1, b, c, d, e, f, g, h }
public static void Main(String[] args)
{
string s = Console.ReadLine();
foreach(char c in s)
{
foreach(int i in Enum.GetValues(typeof(Alphabets)))
Console.WriteLine(s[i]);
}
Console.ReadKey();
}
}
我将用户输入存储在字符串s中。我需要显示用户提供的字符串的整数值。
上面的代码显示了一些错误,如下所示:
我该怎么改正它?或者请给我一个更有效的代码。