Click here to Skip to main content
15,169,285 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
string binary_string = "11100111000010001100000101001000000000000000000110101110010111011110110100000000
0001100001001100000011"
binary_string = binary_string.Substring(90,102);

ERROR: Index and length must refer to a location within the string.
Parameter name: length

PLEASE HELP!!!!!
Posted

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
   
Comments
   
You said "how many string", but that are characters not strings.

Anyways, nice work. Well done. You solved it yourself. :)
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.
   
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.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900