[C#] การใช้ Function แบบ pass-by value และ reference

โค้ด
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int x = 25;
            MessageBox.Show("ก่อนการผ่านค่า x = "+x.ToString(),"pass by value");
            PassValue(x);
            MessageBox.Show("หลังการผ่านค่า x = " + x.ToString(), "pass by value");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int y = 25;
            MessageBox.Show("ก่อนการผ่านค่า x = " + y.ToString(), "pass by reference");
            PassReference(ref y);
            MessageBox.Show("หลังการผ่านค่า x = " + y.ToString(), "pass by reference");
        }

        private void PassValue(int xi)
        {
            xi += 10;
        }
        
        private void PassReference(ref int yi)
        {
            yi += 10;
        }
    }
}

ConversionConversion EmoticonEmoticon

:)
:(
=(
^_^
:D
=D
=)D
|o|
@@,
;)
:-bd
:-d
:p
:ng