日期:2014-05-17 浏览次数:20959 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
/// <summary>
/// 论证方法的参数是否以引用传递。参数以值类型传递
/// </summary>
class Program
{
static void Main(string[] args)
{
string Test = "I Love You!";
Program TestString = new Program();
TestString.ChangeString(Test);
Console.WriteLine(Test);//I Love You!
int[] ints = { 0, 1, 2, 3 };
TestString.ChangeArray(ints);
Console.WriteLine(ints[0].ToString());
Console.ReadKey();
}
public void ChangeString(string str)
{
str = "I heart you";
}
public void ChangeArray(int[] ints)
{
ints[0] = 100;
}