C#相当于Java的charAt()? [英] C# equivalent to Java's charAt()?
本文介绍了C#相当于Java的charAt()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道我们可以在Java中使用 charAt()
方法通过指定字符串的位置来获取字符串中的单个字符。在C#中是否有一个等价的方法?
I know we can use the charAt()
method in Java get an individual character in a string by specifying its position. Is there an equivalent method in C#?
推荐答案
你可以像C#一样在C#中索引一个字符串,然后你得到了这个字符在那个指数。
You can index into a string in C# like an array, and you get the character at that index.
示例:
在Java中,你会说
str.charAt(8);
在C#中,你会说
str[8];
这篇关于C#相当于Java的charAt()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文