我正在尝试将一个字符串分成 2 个子字符串。第一个包含前 236 个(0 到 235)个字符,第二个包含从 237 到字符串末尾的字符。
firststr = str.Substring(0, 235)
secondstr = str.Substring(235, strLength) 'strLength is the total length of the string
strLength 生成错误:索引和长度必须引用字符串中的位置。 参数名称:长度
有什么帮助吗?
最佳答案
你需要这样的东西:
secondstr = str.Substring(235, strLength - 235)
因为 strLength 是整个字符串的长度,并且从位置 235 开始,所以会超过字符串的末尾。
关于vb.net - vb.net 将一个字符串分割成2个不同的子字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6999764/