Is there any way to get nth letter of English alphabet? I want smt similar to this:
有办法得到第n个英文字母吗?我想要smt类似于:
string letter = EnglishAlphabet.GetLetter(5);
//result -> letter is 'E'
I want to use this according to count of my list. If there is 3 elements on my list so "D:D" is enough for me but there is 4 elements then "E:E". I want use this string here:
我想根据我的列表来使用这个。如果我的列表中有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??
Any suggestions? Thanks
有什么建议吗?谢谢
2 个解决方案
#1
11
The simplest approach is:
最简单的方法是:
public string GetLetter(int value)
{
char letter = (char) ('A' - 1 + value);
return letter.ToString();
}
I'd personally change the return type to char
though:
我个人将返回类型改为char:
public char GetLetter(int value)
{
return (char) ('A' - 1 + value);
}
You might want to put some argument validation on there too though...
你也可以在上面加上一些论证。
#2
1
In Excel: =CHAR(64+A1)
where A1 contains the value of n
may suit.
在Excel中:=CHAR(64+A1),其中A1包含n可能适合的值。
#1
11
The simplest approach is:
最简单的方法是:
public string GetLetter(int value)
{
char letter = (char) ('A' - 1 + value);
return letter.ToString();
}
I'd personally change the return type to char
though:
我个人将返回类型改为char:
public char GetLetter(int value)
{
return (char) ('A' - 1 + value);
}
You might want to put some argument validation on there too though...
你也可以在上面加上一些论证。
#2
1
In Excel: =CHAR(64+A1)
where A1 contains the value of n
may suit.
在Excel中:=CHAR(64+A1),其中A1包含n可能适合的值。