I’m a little stuck: I have a string variable which has some data in it which I want to split up as their own values and I don’t know how to do this. Annoyingly, this is the only way to get this information.
So, an EG of the string:
iDealerOptions = Name:Ply Lining Value:£170.00,Name:Bulkhead Value:£200.00
*Note: These names and costs will vary each time but ‘Name:’ and ‘Value:£’ will be consistent.
I want to essentially use ‘Name:’ as a marker and ‘Value’ as another to get the first value (Ply Lining) and then save it as one value, then also get the price for this and have it as another variable, then the same for ‘Bulkhead’ and the price of this also. Perhaps I can somehow put it into a table?
How could I do this? I’m not great with code aha, thanks for your help.
let me know if you need more explained and optimised one but this will work
First split would be for comma so that we can get n sets of name and value
Then replace and split to get name and value separated for each set , you can then have 2 variable
Here is another solution along with a sequence to help you out:
The code is scalable i.e., if there are more line items queued up one after the other, then it will work provided each name, value attributes are separated by a comma.
in this Enumerable.Range(1,2) will give second name and value
similarly change to Enumerable.Range(1,1) will give first name and value
change to Enumerable.Range(1,3) will give the third name and value