Advertisement
DevUModerator

GioFranco

Oct 13th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. namespace ChallengeEpicSpyAssetTracker
  2. {
  3. public partial class Default : System.Web.UI.Page
  4. {
  5. protected void Page_Load(object sender, EventArgs e)
  6. {
  7. if(!Page.IsPostBack)
  8. {
  9. string[] assets = new string[0];
  10. double[] elections = new double[0];
  11. double[] acts = new double[0];
  12. ViewState.Add("Assets", assets);
  13. ViewState.Add("Elections", elections);
  14. ViewState.Add("Acts", acts);
  15. }
  16. }
  17.  
  18. protected void Button1_Click(object sender, EventArgs e)
  19. {
  20. string[] assets = (string[])ViewState["Assets"];
  21. double[] elections = (double[])ViewState["Elections"];
  22. double[] acts = (double[])ViewState["Acts"];
  23.  
  24. //int newIndex = assets.GetUpperBound(0);
  25. int elements = assets.Length + 1;
  26.  
  27. Array.Resize(ref assets, elements);
  28. Array.Resize(ref elections, elements);
  29. Array.Resize(ref acts, elements);
  30.  
  31. int newIndex = assets.GetUpperBound(0);
  32. assets[newIndex] = assetTextBox.Text;
  33. elections[newIndex] = double.Parse(electionsTextBox.Text);
  34. acts[newIndex] = double.Parse(actsTextBox.Text);
  35.  
  36.  
  37. ViewState["Asssets"] = assets;
  38. ViewState["Elections"] = elections;
  39. ViewState["Acts"] = acts;
  40.  
  41. resultLabel.Text= String.Format("Total Elections Rigged: {0} </br>Average of subterfurge per asset{1:N2}</br> (Last Asset Added: {2})",
  42. elections.Sum(), acts.Average(), assets[newIndex]);
  43. //resultLabel.Text = String.Format("Last Asset Added: {2} </br>Elections Total: {0} </br>Average of subterfurge per asset{1:N2}", elections.Sum(), acts.Average(), assets);
  44.  
  45. assetTextBox.Text = "";
  46. electionsTextBox.Text = "";
  47. actsTextBox.Text = "";
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement