Hey all! I’m still a newbie at programming and I decided to move a code from C to C#[VS] and add some textboxes and buttons to it so it looks nicer. Right now I have this code: Pastebin. The idea is:
Box 1: Enter your target int
Box 2:Enter all of the numbers that are allowed in the algorithm (separated ” “)
Box 3:Display all of the combinations
Example:
Box 1:3
Box 2:1 2
Box 3:
1+1+1
1+2
2+1
[THE ISSUE] Everything works when you first click the button. If you don’t restart and press the button again, more combinations appear that should not be there. By looking at my code, I saw that my List keeps getting larger and larger. How should I approach this? Thanks!
Add a call to Allowed.Clear() after DevNum in your button click.
Allowed.Clear()
Thank you so much!
I have a link to Pastebin with my code. I was thinking the same about the clearing. I’ll try it out now.
C# devs
null reference exceptions