String.Split separator won't work with string, only char

I’m using an assign activity to assign a portion of a long sentence into an array using the split method. I changed the method to accept parameters of “String” Type instead of char, but when I am finished typing it all out, it says that I can’t convert “char” type into “String”. I keep changing it to string, but it switches back to char. I don’t know what’s going on with it, but I’m just trying to get a portion of this long sentence, that could be variable length, so I can’t use Substring. Why isn’t it taking my string? Is there something else I can do?

Fine @HsDev
Instead of mentioning like this
yourstring.Split("your character"C, Stringsplitoptions.none)

We can mention like this that would automatically tale the string as a character and vice versa
Like this
Split(“your string”,“your character”)

This would for sure buddy
Kindly try this and let know if you face ant issue
Cheers

2 Likes

@HsDev

Could you please show me some sample text And how are trying to split it.

You can split a string by following way.

String Str = “Robotics Process Automation”

Str.Split(" ".TocharArray)(0) - Robotics

Str.Split(" ".TocharArray)(1) - process

Str.Split(" ".TocharArray)(2) - Automation

Here, I took space as delimiter to split string and will give result as Array of String.

1 Like

The difference is the way the string class called and its method split been used…
Cheers @HsDev

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.