I'm fairly new to C# programming, I have built a simple calculator for my mother to help with her business, and I have taught my self a lot of C++ through out the years. Now I am looking to take this a step further and have most of it contained in the program, with less work for her to do.
Here is a layout of the Form I have. I find it easier to explain what I want it to do with a picture.

Basically, I want her to open it up and click open and browse for a txt file with the recipe name she is looking for. (She creates her own makeup). I then want this recipe to be displayed in the Recipe TextBox. Then I want her to be able to type a number of ounces in the smaller text box below the filepath and click convert. The program would then read the recipe line by line and extract each ingredients name and weight(s) so that I may do calculations with them and return a larger/smaller recipe to the textBox.
Now I can do all this fine, I have a function for opening the file (as in the Load button and Filepath box actually work), and I have set up a function for reading the file.
The problem I have is, some of her recipes may have 2 ingredients, some may have 4 or more etc.
I.e the text files may look like this (Filepaths represent seperate files):
C:\Recipe.txt
10.23g Ingredient1
12.10g Ingredient2
C:\Recipe2.txt
1.02g IngredientX
4.01g Ingredient97
0.09g ThisStuff
1.23g ThisStuff2
What would be the most efficient way to store these variables if I don't know how many there are going to be? I don't want to just create a large array and most of it remained unused. I tried FileHelper library, but it seems to only work with files that have that each object has the same number of variables.
If I could figure this out the rest should be pretty easy.
On a side note, what would be the best format for me to have the .txt files in? (CSV? etc) I'm not too sure with something like this.
I thank anyone who takes the time to read this. As always, any input will be greatly appreciated.

New Topic/Question
Reply



MultiQuote




|