How to split string under C# not VB in Uipath Studio

Pls refer to this picture, I establish a C# process, wish to use Split(),
while it reports error. Any suggestion would be appreciated!

Please like given below

Split(str,β€œ,”).ToArray

The output will be an array, you can put in message box. Just loop through then use message box on it.

Thank you.

try out this syntax

str.Split(","c)

str must be declared in array variable (ex array of strings)

Thanks,

Hi,

We need to use single quote to express char type in C#. So can you try the following?

str.Split(',')

However, this returns array. If we need to express all items, the following works for example.

String.Join(" ",str.Split(','))

FYI

Regards,

Oops. I given the code in VB.

Please see the below for C#



image

Hope this will be helpful. Thank you.

Easy way but don’t get confused with VB

str.Split(β€˜,’)[0] -----> a

str.Split(β€˜,’)[1] ------>b

str.Split(β€˜,’)[2] ------->c

str.Split(β€˜,’)[0] ------->d

Incorrect

str.Split(β€˜,’)(0) ------------> Give you error

This In C# but not in VB

1 Like
str.Split(',' , System.StringSplitOptions.None)[0]

Because of the UiPath library for C# use .net5.0.

String.Split パソッド (System) | Microsoft Learn

2 Likes

Didn’t work here… I tried this first:


Then I tried this:

@cafta13 @lucas1

Can you try like this

Regards
Sudharsan

1 Like

Additional Information

Str.Split(’ ',System.StringSplitOptions.None)--------------------------> this will give as String Array and you can read values through array index such as Str[0].tostring()