C
C#8mo ago
virac

Warehouse Assignment

I'm currently working on my warehouse assignment and I'm kinda stuck. The code is supposed to read line for the inventory file and sets each one to its own warehouse. It's printed after its read to show the starting stock of each warehouse All of the files are being read but the transaction part of the code isn't running. The purchase stock and selling stock parts of the code isn't running and I'm not sure what part is keeping it from doing so. I know this because the final shows the same amount of stock as the beginning of the day. Here is the link to the code and the text files its supposed to interact with. https://paste.mod.gg/rsqxlodzfnro/0
BlazeBin - rsqxlodzfnro
A tool for sharing your source code with the world!
9 Replies
Angius
Angius8mo ago
Did you try debugging?
virac
viracOP8mo ago
Well I know the second text file gets read but I'm not sure if my logic is off somewhere.
Angius
Angius8mo ago
And debugging would help you figure out where $debug
MODiX
MODiX8mo ago
Tutorial: Debug C# code and inspect data - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
Angius
Angius8mo ago
You can use the debugger to trace where the code execution is going, how the variables change, and anything else you want
virac
viracOP8mo ago
i figured it out thank you! turns out the delimeter was case sensitive so just doing ',' wasn't cutting it since in the text files i was reading it was actually ', ' but then i had to switch to ", " because the single quotes can do more than one character as a delimeter
Angius
Angius8mo ago
Alternatively, you could've .Trim()med each element
MODiX
MODiX8mo ago
Angius
REPL Result: Success
var str = "1, 2, 3, 5,7";
var nums = str.Split(',', StringSplitOptions.TrimEntries);
nums
var str = "1, 2, 3, 5,7";
var nums = str.Split(',', StringSplitOptions.TrimEntries);
nums
Result: string[]
[
"1",
"2",
"3",
"5",
"7"
]
[
"1",
"2",
"3",
"5",
"7"
]
Compile: 364.243ms | Execution: 23.727ms | React with ❌ to remove this embed.
Angius
Angius8mo ago
Or, well, to be precise, no need to trim them. String split already has an option to trim them for you That's what you see in the above snippet
Want results from more Discord servers?
Add your server