Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split a string by a character

Tags:

c#

.net

I have this string here:

String FileNameOrginal = "lighthouse-126.jpg";

and I am trying to split the string into 2, seperating it with "-"

I have tried the following, but I get a syntax error on the Spilt:

String FileNameOrginal = drProduct["productHTML"].ToString();
string[] strDataArray = FileNameOrginal.Split("-");

Please Help, I do not understand what I am doing wrong.

like image 209
user2615353 Avatar asked Nov 19 '25 18:11

user2615353


1 Answers

You just need a character instead of string:

string[] strDataArray = FileNameOrginal.Split('-');
like image 54
Joel Coehoorn Avatar answered Nov 21 '25 08:11

Joel Coehoorn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!