コード例 #1
0
 private void button3_Click(object sender, EventArgs e)
 {
     Elephant temp = lloyd;
     lloyd = lucinda;
     lucinda = temp;
     MessageBox.Show("Objects swapped");
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: linuxemb/C_sharp
        private void bigestEar_Click(object sender, EventArgs e)
        {
            Elephant[] elephants = new Elephant[7];
            elephants[0] = new Elephant()
            {
                Name = "Lioyd", EarSize = 40
            };
            elephants[1] = new Elephant()
            {
                Name = "L", EarSize = 33
            };
            elephants[2] = new Elephant()
            {
                Name = "Li", EarSize = 25
            };
            elephants[3] = new Elephant()
            {
                Name = "Lio", EarSize = 43
            };
            elephants[4] = new Elephant()
            {
                Name = "Lioy", EarSize = 23
            };
            elephants[5] = new Elephant()
            {
                Name = "Lioyd", EarSize = 240
            };
            elephants[6] = new Elephant()
            {
                Name = "Lioyda", EarSize = 140
            };

            Elephant biggestEars = elephants[0];

            for (int i = 0; i < elephants.Length; i++)
            {
                if (elephants[i].EarSize > biggestEars.EarSize)
                {
                    biggestEars = elephants[i];
                }
            }
            MessageBox.Show(biggestEars.EarSize.ToString());
        }
コード例 #3
0
        private void button5_Click(object sender, EventArgs e)
        {
            Elephant[] elephants = new Elephant[7];
            elephants[0] = new Elephant()
            {
                Name = "Lloyd", EarSize = 40
            };
            elephants[1] = new Elephant()
            {
                Name = "Lucinda", EarSize = 33
            };
            elephants[2] = new Elephant()
            {
                Name = "Larry", EarSize = 42
            };
            elephants[3] = new Elephant()
            {
                Name = "Lucille", EarSize = 32
            };
            elephants[4] = new Elephant()
            {
                Name = "Lars", EarSize = 44
            };
            elephants[5] = new Elephant()
            {
                Name = "Linda", EarSize = 37
            };
            elephants[6] = new Elephant()
            {
                Name = "Humphrey", EarSize = 45
            };
            Elephant biggestEars = elephants[0];

            for (int i = 1; i < elephants.Length; i++)
            {
                if (elephants[i].EarSize > biggestEars.EarSize)
                {
                    biggestEars = elephants[i];
                }
            }
            MessageBox.Show(biggestEars.EarSize.ToString());
        }
コード例 #4
0
 public Form1()
 {
     lucinda = new Elephant(){Name="Lucinda", EarSize=33};
     lloyd = new Elephant() { Name = "Lloyd", EarSize = 40 };
     InitializeComponent();
 }
コード例 #5
0
 private void button4_Click(object sender, EventArgs e)
 {
     lloyd         = lucinda;
     lloyd.EarSize = 4512;
     lloyd.WhoAmI();
 }
コード例 #6
0
 public void SpeakTo(Elephant whoToTalkTo, string message)
 {
     whoToTalkTo.TellMe(message, this);
 }
コード例 #7
0
 public void TellMe(string message, Elephant whoSaidIt)
 {
     MessageBox.Show(whoSaidIt.Name + " says: " + message);
 }
コード例 #8
0
 public void TellMe(string message, Elephant whoSaidIt)
 {
     MessageBox.Show(whoSaidIt.Name + " says: " + message);
 }
コード例 #9
0
 public void SpeakTo(Elephant whoToTalkTo, string message)
 {
     whoToTalkTo.TellMe(message, this);
 }
コード例 #10
0
ファイル: Elephant.cs プロジェクト: linuxemb/C_sharp
 public void SpeakTo(Elephant talkto, string message)
 {
     talkto.TellMe(message, this);
 }