Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Elephant
- {
- public string Name { get; set; }
- public int EarSize { get; set; }
- public Elephant(string name, int earSize)
- {
- Name = name;
- EarSize = earSize;
- }
- public void WhoIAm()
- {
- MessageBox.Show("My name is " + Name + " and my ears are " + EarSize + " inches tall.");
- }
- public partial class Form1 : Form
- {
- Elephant elephant1;
- Elephant elephant2;
- public Form1()
- {
- InitializeComponent();
- Elephant elephant1 = new Elephant("Братишка", 20);
- Elephant elephant2 = new Elephant("Пахом", 20);
- }
- private void button3_Click(object sender, EventArgs e)
- {
- Elephant elephantSwap = elephant1;
- elephant1 = elephant2;
- elephant2 = elephantSwap;
- MessageBox.Show("Поменяно.");
- Console.WriteLine(elephant1.Name, elephant1.EarSize);
- }
- private void button1_Click(object sender, EventArgs e)
- {
- elephant1.WhoIAm();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- elephant2.WhoIAm();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment