c# - How to control flow from one function to another function -
i trying call chk_condition()
function find_output()
problem control not moving find_output() function chk_condition() function. possible error?
private void find_output(string a) { string[] separators = new string[] { "\n" }; foreach (string sent in a.split(separators) { listbox8.items.clear(); string sentence = sent.replace("\r", ""); if (sentence != "") { int s = sentence.count(); string[] separators1 = new string[] { " " }; foreach (string word in sentence.split(separators1)) { listbox8.items.add(word); } int word_count = listbox8.items.count; chk_condition(sentence); if (condition_satisfy == i) textbox6.text = textbox6.text + environment.newline + sentence; } } } private void chk_condition(string a) { }
assuming code compiles - because there obvious errors** - can debug find_output
method check why chk_condition
never executed. 1 reason may string a
empty or program breaks before reaching chk_condition
.
i'm assuming using visual studio. debug:
- set breakpoint (f9) @ beginning of
find_output
. - start application in debug mode (f5).
- when breakpoint hit go step step (f10) see line line how code executed.
- while debugging use mouse , hover on variables see current values (or use e.g. watch window (ctrl+d,w).
- if
sentence
string not empty reachchk_condition
. use step inside (f11) see method executed.
** missing closing bracket in first foreach loop. mysterious i
variable - initialized anywhere? have value?
Comments
Post a Comment