Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I substring an ID?

I got a ID which are LSHOE-UCT. How can I substring and seperate those ID in order to become:

gender = "L"
Product = "Shoe"
Category = "UCT"

Here is my code:

    private void assignProductCategory(string AcStockCategoryID)
    {
        //What should I insert?
        string[] splitParameter = AcStockCategoryID.Split('-');

    }

I need to seperate those, ID them and insert to difference table from my database. And that is where I am having the main problem

like image 347
user998405 Avatar asked Jun 20 '26 20:06

user998405


1 Answers

string[] s = AcStockCategoryID.Split('-');
string gender = s[0].Substring(0, 1);
string Product= s[0].Substring(1, s[0].Length - 1);
string Category = s[1];
like image 110
Omar Avatar answered Jun 22 '26 09:06

Omar



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!