如何回报这是该指数在字符?这是、字符、指数

2023-09-04 09:26:30 作者:我是妳的稻草人

我知道,我可以返回一个字符串的indexOf()函数的特定字符的索引。 但是,我怎么能与特定的索引返回字符?

解决方案

 字符串s =你好;
焦炭C = S [1];
//现在ç=='E'
 

另请参见子串,返回多个字符。

I know that i could return the index of a particular character of a string with indexof() function. But how i could return the character with the particular index?

解决方案 12年上涨11倍的指数,目前仍然低估

string s = "hello";
char c = s[1];
// now c == 'e'

See also Substring, to return more than one character.