Note that there are some explanatory texts on larger screens.

plurals
  1. POString.Substring explanation
    primarykey
    data
    text
    <p>In my program I have a long string sent via another program. This string is roughly 100 characters long and I only need a small portion of it. For this, we'll say the string I'm sending is as follows:</p> <blockquote> <p>Hello, I am a test string. I am awfully long and full of things you don't want. </p> </blockquote> <p>So, to cut the string so I only get the portion I need I have used the following string method:</p> <pre><code>String.Substring(startPoint, Endpoint) </code></pre> <p>Now in my program I know that the bit of the string I need to use is exactly 38 characters from the start and is only 36 characters long. Thus my call looks something like this:</p> <pre><code> String.Substring(38, 36) </code></pre> <p>And my program will happily read in <code>test string</code> from the above example. </p> <p>This doesnt show up any issues or bugs when I build the program. But when I run it, the computer complains that the end point can't be lower than the start point. The thing is, however, the part of the message I want, gets sent over. </p> <p>I've tried modifying my call so that it would look similar to this:</p> <pre><code>String.Substring(startPoint, startPoint + 36) </code></pre> <p>But that has returned a bunch of extra characters I don't need or want. </p> <p>Now my thinking behind that method is that it works by taking my initial point, the 38th character from the beginning of the string, and then goes 36 characters along from the 38th. Is my thinking behind how this method works wrong?</p> <p>Why does this computer complain about an issue but then does what I want anyway?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload