Files
ASDV-C-Sharp/Student Sample Programs/Chap06/Pass By Value/Pass By Value/Form1.cs
2022-08-30 14:15:11 -05:00

43 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Pass_By_Value
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void goButton_Click(object sender, EventArgs e)
{
int number = 99;
// Display the value of number.
MessageBox.Show("The value of number is " + number);
// Call ChangeMe, passing number as an argument.
ChangeMe(number);
// Display the value of number again.
MessageBox.Show("The value of number is " + number);
}
private void ChangeMe(int myValue)
{
// Change the value of the myValue parameter.
myValue = 0;
// Display the value of myValue.
MessageBox.Show("In ChangeMe, myValue is " + myValue);
}
}
}