Explanation for String Function

Greetings of the Day

ClientInformation.Substring(ClientInformation.IndexOf(“ClientId:”)+“ClientID:”.Length).Split(Environment.NewLine.ToCharArray)(0)

Can Anyone give me the explanation for this string function

Thanks
Soumiya

Hi @soumi_soumiya
Can you provide the value of ClientInformation Variable.

hello @soumi_soumiya

ClientInformation.Substring(ClientInformation.IndexOf(“ClientId:”)+“ClientID:”.Length)

above expression will give you a sub string from the main, string will start from 0th index and ends at sum of ClientInformation.IndexOf(“ClientId:”)+“ClientID:”.Length

means length will be sum of ClientInformation.IndexOf(“ClientId:”)
and “ClientID:”.Length

.Split(Environment.NewLine.ToCharArray)(0) this expression will split the resultant string from the first express based on new line char and return the string in the 0th index.

REgards
Ajay

ACME System 1 - Work Items

Client ID: AD55686
Client Name: Digna Buffaloe
Client Country: Germany

@soumi_soumiya

  • ClientInformation.Substring(ClientInformation.IndexOf(“ClientId:”)+“ClientID:”.Length) It will give you substring from Whole string starting from ClientId Till the Client Id: Because you have mentioned it as Hard coded If its Variable then Till the value stored It in.
  • Split(Environment.NewLine.ToCharArray)(0) It will split the string Using NewLine and will give you the First value i.e. 0th Index.

will it returns the value AD55686
name and country

@soumi_soumiya

  • To get that value of ClientId
    ClientInformation.Split(cchar(Environment.NewLine))(0).Split(cchar(“:”))(1)
  • To get the value of Name
    ClientInformation.Split(cchar(Environment.NewLine))(1).Split(cchar(“:”))(1)
  • To get Country use
    ClientInformation.Split(cchar(Environment.NewLine))(2).Split(cchar(“:”))(1)

Hey @soumi_soumiya

you can use below

For Client ID -

ClientInformation.Substring(ClientInformation.IndexOf("Client ID: ")+"Client ID: ".Length).Split(Environment.NewLine.ToCharArray)(0)

For Client Name -

ClientInformation.Substring(ClientInformation.IndexOf("Client Name: ")+"Client Name: ".Length).Split(Environment.NewLine.ToCharArray)(0)

For ClientCountry -

ClientInformation.Substring(ClientInformation.IndexOf("Client Country: ")+"Client Country: ".Length).Split(Environment.NewLine.ToCharArray)(0)

Regards…!!
Aksh

1 Like