Try this:
string myStr= "46917 - Shampoo";
if (myStr.Contains('-')) {
string[] tokens = myStr.Split('-');
int i = Convert.ToInt32(tokens[0].Trim());
}
solved Split string and convert to integer in C#
Try this:
string myStr= "46917 - Shampoo";
if (myStr.Contains('-')) {
string[] tokens = myStr.Split('-');
int i = Convert.ToInt32(tokens[0].Trim());
}
solved Split string and convert to integer in C#