arrays - Using streamreader in c# -


how guys use streamreader read .txt file , match 2 of combobox's text such sgd - singapore dollar , usd - dollar writes on label shows number of 1.26?

exchange.txt:

sgd - singapore dollar || usd - dollar = 1.26

here's code:

private void getexchangerate() {     using (streamreader sr = new streamreader("exchange.txt"))     {         string[] store = new string[100];         int index = 0;         string line;          while ((line = sr.readline()) != null)         {             store[index] = line;             index++;             lblexchange.text = sr.readline();         }     } }  private void tocountry_selectedindexchanged(object sender, eventargs e) {     btnupdate.enabled = true;     txtvalue.enabled = true;     getexchangerate(); } 

in end, label did not show value of 1.26. don't know what's wrong it. need help

you can

private void getexchangerate() {     string[] lines = file.readalllines("exchange.txt");      foreach (var line in lines) {          //suppose line contains 'singapore' , want somthing if line contains singapore should           if(line.contains("singapore"))           {                lbldisplay.text = "singapore"           }        //do functionality line display depending upon country        // can match line , display them according need       }  } 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -