using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace __9
{
class Program
{
static void Main(string[] args)
{
int a = 3;
testprimitive(a);
Console.WriteLine(a); //3
ArrayList l = new ArrayList();
Console.WriteLine(l.Count); //0
textobjectlist(l);
Console.WriteLine(l.Count); //?2
print(l);
Console.WriteLine("-------------");
ArrayList ll = new ArrayList();
ll.Add("major");
Console.WriteLine(ll.Count); //1
print(ll);
Console.WriteLine("--------------");
textobjectlist2(ll);
Console.WriteLine(ll.Count); //?1
print(ll);
Console.WriteLine("....---------------");
string s = "jack";
teststring(s);
Console.WriteLine(s); //jack
}
private static void testprimitive(int a)
{
a *= 2;
}
private static void textobjectlist(ArrayList l)
{
l.Add("jumbo");
l.Add("jumbo2");
}
private static void textobjectlist2(ArrayList l)
{
l = null; //l 指向null引用,以前的那个对象并没有变
//l.Add("a");
//l.Add("b");
}
private static void teststring(string s)
{
s = "john";
}
private static void print(ArrayList l)
{
foreach(string s in l)
{
Console.WriteLine(s);
}
}
}
}
评论