ArrayList constructor arguments

I wrote this code.

void Start () {
	ArrayList v = new ArrayList(1,2,3);
	Debug.Log(v.Count);  //3
	new Foo(v);
	Debug.Log(v.Count);  //0
}

class Foo{
	public Foo(a :ArrayList){
		a.Clear();
	}
}

Why did v become 0?

Because ArrayList is a reference type, you are passing a pointer to the actual ā€œvā€ ArrayList when you suply it as a parameter for the constructor.

To know more about this google ā€œc# reference type vs value typeā€, there is so much material regarding this topic that it would be wrong to link a single one.