How to Prove Array as a Reference type variable ?


As, we know that variables like int, float, double etc. are value type and Array is a reference type variable. To, prove this by a program here we go:


1: let define and declare 2 different array and name them according to you, I’ve given them name as array1 and array2.

2: I’ve put their values as {1,2,3} for first and {10,20,30} for second.

3: Check their values through message box.

4: Now Let’s assign the value of array2 to array1.

5: Now, explicitly change the value of 1st element of array1.

6: Now, check the value of 1st element of Array2.


and you’ll see that the value of array2 is changed by default and this is a property of reference type.



Source Code:

namespace To_Prove_Array_As_a_Reference


public partial class FrmArrayAsaReference : Form


public FrmArrayAsaReference()




private void btnonclick_Click(object sender, EventArgs e)


int[] array1 = { 1, 2, 3 };

int[] array2 = { 10, 20, 30 };

array1 = array2;



array1[1] = 100;





Output2 output

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s