0

I've been tasked with making a program that downloads prices for various tools that our company uses. The data is a simple JSON format with the tool number, price, etc. Usually looks like this:

"ReferenceItemId":"T0430",
"BaseUnitPrice":59.100000000,

With the tool number being 0430 and the price being $59.10. My program makes an entry in our database with the tool number and price. I've got it working on a basic level, but luckily for me, our tool supplier sometimes adds multiple tools for one entry.

"ReferenceItemId":"IMC63504 T0603 T0885 T3603 T0942 T3604 T3605 T6007 T1082 T0703",
"BaseUnitPrice":48.710000000,

So I need to figure out how to split this string up into an array. Once I have that I can make an entry in our database for each tool in the array. Also, the first word is garbage, so I need to delete that, and it isn't a consistent length (or removing it would be easy!). Any advice is appreciated! Thanks.

1
  • 4
    It's still easy regardless of the length. Have you tried to Split() the string? Commented Oct 1, 2021 at 20:37

1 Answer 1

1

You can use String.Split method like this

string s = "You win some. You lose some.";

string[] subs = s.Split(' ');

foreach (var sub in subs)
{
    Console.WriteLine($"Substring: {sub}");
}

// This example produces the following output:
//
// Substring: You
// Substring: win
// Substring: some.
// Substring: You
// Substring: lose
// Substring: some.
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.