ref -----雙向傳遞 數(shù)據(jù) ----必須是instance 好的
out ----- 只是出來(lái)不進(jìn)去的 , 給個(gè)引用就可以了
a 作為ref的 傳遞進(jìn)去必須先要初始化一個(gè) instance 的空間
否則編譯出錯(cuò)。


string a ;//Test.cs(51,29): error CS0165: 使用了未賦值的局部變量“a”

max ( ref a ,ref b , out str1 , out j );


static void max( ref string x, ref string y , out string a , out int b )
{
。。。
}



out 變量
string str1 ="U ---"; // out 作為 out 只需要定義一個(gè)引用
在外面調(diào)用的地方即使 給了實(shí)例 ,進(jìn)入到函數(shù)體里面也不能用。所以只需要引用就可以了。
max ( ref a ,ref b , out str1 , out j );
static void max( ref string x, ref string y , out string a , out int b ) {
string o = null;
a = a+ "max"; // Test.cs(37,23): //error error CS0269: 使用了未賦值的 out 參數(shù)“a”