ref -----雙向傳遞 數據 ----必須是instance 好的
out ----- 只是出來不進去的 , 給個引用就可以了
a 作為ref的 傳遞進去必須先要初始化一個 instance 的空間
否則編譯出錯。


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 只需要定義一個引用
在外面調用的地方即使 給了實例 ,進入到函數體里面也不能用。所以只需要引用就可以了。
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 參數“a”