Answers:
您可以像数组一样索引C#中的字符串,然后在该索引处获取字符。
例:
在Java中,您会说
str.charAt(8);
在C#中,您会说
str[8];
string sample = "ratty";
Console.WriteLine(sample[0]);
和
Console.WriteLine(sample.Chars(0));
参考:http : //msdn.microsoft.com/zh-cn/library/system.string.chars%28v=VS.71%29.aspx
上面与在c#中使用索引器相同。
只需使用String.ElementAt()
。它与java的非常相似String.charAt()
。祝您编码愉快!