假设我们有一个长度非常大的字符串,比 max_int 还要大。
string str="this should contain a long string";
如果我想访问 str[100000000000]
。
我应该怎么做?
当我尝试放置一个类型不是 int 的索引时,出现以下错误:
The best overloaded method match for 'string.this[int]' has some invalid arguments
最佳答案
你不能。我不相信你可以拥有一个超过 2^32 字节的对象,所以你真的不会遇到这个问题。
根据 this post最大 CLR 对象大小为 2GB,这证实了我的说法。
关于c# - 如何获取索引大于 max_int 的数组元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12946154/