A Simple User-defined Method


// Code from text with slight mods (Wyatt)
//
using System;
using System.Windows.Forms;

namespace Simple_Method
{
    public partial class Form1 : Form
    {
        // constructor
        public Form1()
        {
            InitializeComponent(); // builds GUI
        }

        
        // button click as before except that it CALLS a user-defined method
        private void goButton_Click(object sender, EventArgs e)
        {
            MessageBox.Show("This is the goButton_Click method.");
            
            // this is the call to the user-defined method
            DisplayMessage();
            
            MessageBox.Show("Back in the goButton_Click method.");
        }

        
        // this is the user-defined method - ONLY executed when called
        private void DisplayMessage()
        {
            MessageBox.Show("This is the DisplayMessage method.");
        }
    }
}