如何获得英文字母的第n个字母

cih*_*a87 3 excel alphabet c#-4.0

有没有办法得到英文字母的第n个字母?我想smt与此类似:

string letter = EnglishAlphabet.GetLetter(5);
//result -> letter is 'E'
Run Code Online (Sandbox Code Playgroud)

我想根据我的清单计算使用它.如果我的列表中有3个元素,那么"D:D"对我来说已经足够了,但是有4个元素,那么"E:E".我想在这里使用这个字符串:

 Excel.Range chartRange;    
 Excel.ChartObjects xlCharts = (Excel.ChartObjects)xlWorkSheet.ChartObjects(Type.Missing);
 Excel.ChartObject myChart = xlCharts.Add(5, 5, 540, 160);
 Excel.Chart chartPage = myChart.Chart;    
 chartRange = xlWorkSheet.get_Range("A:A", "D:D");//"D:D" changes according to size of the list??
Run Code Online (Sandbox Code Playgroud)

有什么建议?谢谢

Jon*_*eet 13

最简单的方法是:

public string GetLetter(int value)
{
    char letter = (char) ('A' - 1 + value);
    return letter.ToString();
}
Run Code Online (Sandbox Code Playgroud)

我个人将返回类型更改为char:

public char GetLetter(int value)
{
    return (char) ('A' - 1 + value);
}
Run Code Online (Sandbox Code Playgroud)

你可能也希望在那里进行一些参数验证......