index和length必须引用字符串中的位置 [英] index and length must refer to a location within the string

查看:134
本文介绍了index和length必须引用字符串中的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string binary_string =11100111000010001100000101001000000000000000000110101110010111011110110100000000

0001100001001100000011

binary_string = binary_string.Substring(90,102);



错误:索引和长度必须指代字符串中的位置。

参数名称:长度



请帮助!! !!!

推荐答案

我想出来了,substring()的第二个参数实际上是问你从第一个起始位置得到多少个字符串substring()的参数。



Ex。 string str =HelloWorld!; \\ H是0的索引。
I figured out, second parameter of substring() is actually asking you how many string do you want from the starting position of first argument of substring()).

Ex. string str = "HelloWorld!"; \\ H is index of 0
str = str.Substring(1,7); \\ equal to elloWor


第二个参数表示新字符串中需要多少个字符,第一个参数表示新字符串开始的位置。在原始字符串中,从90开始就没有足够的120个字符。
the second parameter means how many characters you want in the new string ,and the first parameter means the position the new string begins.so in your original string ,from the 90 there are not 120 characters enough.


从框架类调用函数时,intellisence(Ctrl + Space | Ctrl + Shift + Space)有很大的帮助,它给你一个简短的方法和方法参数的描述可以为您节省大量时间。
When calling functions from framework classes the intellisence (Ctrl+Space | Ctrl+Shift+Space) is of great help, it gives you one short description for methods and method parameters that saves you a lot of time.


这篇关于index和length必须引用字符串中的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆