What I wanted to do in my coding is to be able to parse and store the value of <selects> and their <options> so that I would be able to use them later in my other functions. I decided to use structs (declared as array) as there can be many <select> in a webpage and use arraylist to save their options. So that when calling them, it would look like select[1].options[1] or select[1].options[2]... etc.
My coding goes something like this:
Expand|Select|Wrap|Line Numbers
- class Parser {
- static Select[] selects = new Select[100];
- //declared so it can be called in other fuctions however, is there a way so that even if selects is not global and declared in main, it can still be called on loop function?
- public struct Select
- {
- public string selectname;
- public int selectnumber;
- public String[] options;
- public Select()
- {
- options = new String[20];
- //the error I get here is: structs cannot contain explicit parameterless constructors - I have absolutely no idea what parameter to put in there since in main, I also have selects[selectcount].selectname = selectname; and selects[selectcount].selectnumber = selectnumber; and a for(;;) selects[selectcount].options[i]=value;
- }
- }
- static int Main(string[] args)
- {
- //my code is long.. XD this is a shortcut :D
- selects[selectcount].selectname = selectname; selects[selectcount].selectnumber = selectnumber;
- for(;;)
- selects[selectcount].options[i]=value;
- recursiveloop(selectcount, selects[selectcount].selectnumber);
- }
- public void recursiveloop(int limit, int num)
- {
- //the fuction i've been talking about where...
- String valuehere;
- for(;;)
- if (condition here)
- valuehere += selects[fixedvaluehere].option[i]; //it does not recognize selects if I don't declare it global.
- else
- recursiveloop();
- display(valuehere);
- }
- }