c# - WPF program won't load after code change -


application working fine until added code 2 arrays. have class level strings:

string cfilename = "customer.txt"; string[] cname = new string[0]; string[] cphone = new string[0]; 

and i've added window_loaded event:

private void window_loaded_1(object sender, routedeventargs e) {     //read file on start     //readfile();     int counter = 0;     string line;     streamreader custsr = new streamreader(cfilename);     line = custsr.readline();      while (custsr.peek() != -1)     {         array.resize(ref cphone, cphone.length + 1);         array.resize(ref cname, cname.length + 1);          cphone[cphone.length - 1] = line;         cname[cname.length - 1] = line;         counter++;          //phonecombobox.items.add(cphone[cphone.length - 1]);      }      custsr.close();       (int = 0; < counter; i++)      {          phonecombobox.items.add(cphone[i]);      }      //focus when program starts      phonecombobox.focus(); } 

the reason have //readfile() because tried have separate method , call window_loaded event. tried ouputting combo box within loop. have not had happen before , can't figure out i've done.

i not reading next line break loop. i'm marking answer fixed issue , incase happens stumble across issue in future.

while (custsr.peek() != -1) {     array.resize(ref cphone, cphone.length + 1);     array.resize(ref cname, cname.length + 1);      cphone[cphone.length - 1] = line;     cname[cname.length - 1] = line;     counter++;      line = custsr.readline();  //needed read next line  } 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -