Split a string and assign a element to variable

Hi All,

Can any one advice me how to split a string and assign the element to variable in a single step.
Ex: My string is “Hello UIpath”
now I will split the string based on space and I want to assign “UIpath” to string variable.
Basically this helps me to reduce one step and creation of one variable, please advice.

Thanks,
Hari

@harinathreddy.yn

string a = “Hello UIpath”

string b = string a.Split({" "},stringSplitOptions.RemoveEmptyEntries).ToArray(1).ToString

Now string b contains Uipath.

After splitting you have to give the index of the word which you have to extract. here the index of uipath is 1

Regards,
Mahesh

1 Like

@harinathreddy.yn

                              Assign str1 = "Hello Uipath"
                              Assign str1 = str1.Split(" ".ToCharArray)(1).ToString
1 Like

Hi @MAHESH1,
Thanks for the solution. It served my purpose.

Regards,
Hari