C
C#2y ago
Kyhro

❔ How to display a class property in a list box ?

I am working on a recipe book software for uni and I have troubles displaying a class property in a listbox. I have an array of classes and I need to display the name property of the class in a listbox. I figured something is wrong with my display() method since the values are correctly retrieved (I checked it with message box). Can anyone tell me what I am doing wrong here ?
8 Replies
TheBoxyBear
TheBoxyBear2y ago
It's adding the value of showing and not Name Also since the methods are only using the index to retrieve the recipe, you can change the parameters to take a single recipe instead and index the array inside the calls 🙂
Kyhro
KyhroOP2y ago
sorry I forgot to add more context, basically the class display is supposed to be called after a name of recipe got input by the user, it's called from the method addRecipe located in the class Recipe
TheBoxyBear
TheBoxyBear2y ago
So what is the expected result?
Kyhro
KyhroOP2y ago
to add the name property of the class Recipe to a listbox this property is a string and the class instance recipe is located in an array of class instances "recipes"
TheBoxyBear
TheBoxyBear2y ago
how is addRecipe called?
Kyhro
KyhroOP2y ago
it's a chain triggered by clicking the button
TheBoxyBear
TheBoxyBear2y ago
Hard to tell without the full code. Use breakpoints to check the values at runtime and see where's it's different than expected.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server