Posted By

c on 04/30/12


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BrockSamsom


findLarger


 / Published in: C#
 

findLarger

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8.  
  9. namespace method_calling
  10. {
  11. public partial class Form1 : Form
  12. {
  13. public Form1()
  14. {
  15. InitializeComponent();
  16. }
  17.  
  18. private void button1_Click(object sender, EventArgs e)
  19. {
  20. int anInteger1;
  21. anInteger1 = Convert.ToInt32(textBox1.Text);
  22. anInteger1 = int.Parse(textBox1.Text);
  23.  
  24. int anInteger2;
  25. anInteger2 = Convert.ToInt32(textBox2.Text);
  26. anInteger2 = int.Parse(textBox2.Text);
  27.  
  28. int answer;
  29. answer = findLarger(anInteger1, anInteger2);
  30. MessageBox.Show("The larger numbers is " + answer);
  31. }
  32.  
  33. public static int findLarger(int a, int b)
  34. {
  35. int largerNum;
  36.  
  37. if (a > b)
  38. largerNum = a;
  39. else
  40. largerNum = b;
  41.  
  42. return largerNum;
  43. }
  44.  
  45. private void textBox1_TextChanged(object sender, EventArgs e)
  46. {
  47.  
  48. }
  49.  
  50. }
  51. }

Report this snippet  

You need to login to post a comment.