class Program
{
    
static void Main()
    {
        
string input1 = "123456";
        GetStr1(input1);
        Console.WriteLine(input1);

        
string input2 = "123456";
        GetStr2(
ref input2);
        Console.WriteLine(input2);

        
string input3 = "123456";
        GetStr3(
out input3);
        Console.WriteLine(input3);

        Console.ReadLine();
    }

    
static string GetStr1(string input)
    {
        input 
= "Hello";
        
return input;
    }

    
static string GetStr2(ref string input)
    {
        input 
= "Hello";
        
return input;
    }

    
static string GetStr3(out string input)
    {
        input 
= "Hello";
        
return input;
    }
}

Result is:
123456
Hello
Hello

Actual:
string input2 = null;
string input3 = null;

Result is the same.
posted on 2009-07-23 12:21  huadust  阅读(228)  评论(0编辑  收藏  举报