我知道我可以使用 indexof()
函数返回字符串中特定字符的索引,但是如何返回特定索引处的字符?
最佳答案
string s = "hello";
char c = s[1];
// now c == 'e'
另请参阅 Substring
,以返回多个字符。
关于c# - 如何通过索引获取字符串中的字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2416894/
我知道我可以使用 indexof()
函数返回字符串中特定字符的索引,但是如何返回特定索引处的字符?
最佳答案
string s = "hello";
char c = s[1];
// now c == 'e'
另请参阅 Substring
,以返回多个字符。
关于c# - 如何通过索引获取字符串中的字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2416894/