Advertisement
gothbarbie

Untitled

Nov 27th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1.         static void WriteFile(string filename, string text)
  2.         {
  3.             File.WriteAllText(filename, text);
  4.         }
  5.  
  6.         static string ReadFile(string filename)
  7.         {
  8.             return File.ReadAllText(filename);
  9.         }
  10.  
  11.         private void btnAddNr_Click(object sender, EventArgs e)
  12.         {
  13.             string text = txtInput.Text;
  14.  
  15.             WriteFile(filename, text + Environment.NewLine);
  16.         }
  17.  
  18.         private void btnGetMean_Click(object sender, EventArgs e)
  19.         {
  20.             string text = ReadFile(filename);
  21.            
  22.             string[] lines = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
  23.  
  24.             int summa = 0;
  25.  
  26.             foreach (string line in lines)
  27.             {
  28.                  summa += Convert.ToInt16(line);
  29.             }
  30.  
  31.            
  32.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement