Level 3 excersise 2: Extracting the TaxId from vendor information

Hi guys, I got a bit of unexpected behaviour and I hoped someone here could explain to me why I’m getting this output.
To extract the taxId from the detailpage, I use a get text, indicated the whole paragraf with the clientinfo and tried to create a substring of that:

clientInfo.Substring("TaxId: ".Length,clientInfo.IndexOf(Environment.NewLine))

So the substring start ad the end of the label until it reaches a new line, the startindex is correct, but for some reasson I’m getting the namelabel, which is on the next line, too. The same if I change it to:

clientInfo.Substring("TaxId: ".Length, "TaxId: ".Length +8)

since the taxId is always 8 chars.
When I use:
clientInfo.Substring("TaxId: ".Length).Split(Environment.NewLine.ToCharArray)(0)
it works, but it seems overcomplicated to me
Could someone explain to me why? It dosn’t make sence to me

@Daniel_D

It should be like this:

clientInfo.Substring(clientInfo.IndexOf("TaxId: ")+"TaxId: " .Length).Split(Environment.NewLine.ToCharArray)(0)

For your reference please check below thread.

Level 3 Assignment1 - Need help with pg.13 - #6 by lakshman

That dosn’t answer my question. There’s never only one way to do things. I found something that Works, I’m a java developer and java uses the same functions, my questions was when I take a substring untill the newline, why dosn’t he cut off at the start of the newline, but adds the extra chars. Everyone can copy something, I was trying to understand what happens. And no offence, but I still think that
clientInfo.Substring("TaxId: ".Length).Split(Environment.NewLine.ToCharArray)(0)
is cleaner then
clientInfo.Substring(clientInfo.IndexOf("TaxId: ")+"TaxId: ".Length).Split(Environment.NewLine.ToCharArray)(0)
We already know that the taxIdlabel will always start at index(O) so why ask for the index and then at the length of the label, just start at the end of the label