using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ch6_12
{
    public partial class Form1 : Form
    {
        public void modifyArray(int[] b)
        {
            for (int i = 0; i < b.Length; i++)
                b[i] *= b[i];
        }
        public void modifyElement(int e1, ref int e2)
        {
            e1 *= 10;
            e2 *= 10;
        }

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int[] a = { 1, 2, 3, 4, 5 };
            label1.Text = "Initial array elements :";
            foreach (int num in a)
                label1.Text += "  " + num.ToString ();
            modifyElement(a[1], ref a[2]);
            label1.Text += "\nEffect of passing array elemnts :\n" +
                "by value and by reference : " +
                " a[1] = " + a[1] + ", a[2] = " + a[2];
            label1.Text += "\n\nEffets of passing arry :";
            label1.Text += "\nBefore pass to method :";
            foreach (int num in a)
                label1.Text += "  " + num.ToString ();
            modifyArray(a);
            label1.Text += "\nAfter return from method :";
            foreach (int num in a)
               label1.Text += "  " + num.ToString ();
        }
    }
}
