JUST DO IT ~

          我只想當個程序員

          out ref 作為函數的參數

          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”

           




          posted on 2008-03-26 20:57 小高 閱讀(373) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

          <2008年3月>
          2425262728291
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          統計

          常用鏈接

          留言簿(3)

          隨筆分類(352)

          收藏夾(19)

          關注的blog

          手冊

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 历史| 土默特右旗| 滨海县| 花莲县| 天水市| 德江县| 将乐县| 合水县| 恩施市| 卓尼县| 张家川| 东台市| 惠安县| 锡林浩特市| 桓台县| 厦门市| 讷河市| 凉山| 房山区| 工布江达县| 聂荣县| 神农架林区| 邵阳县| 大丰市| 堆龙德庆县| 桑植县| 神池县| 广汉市| 诸暨市| 内江市| 新乡市| 夏河县| 杭锦旗| 孟津县| 吉隆县| 冀州市| 鄢陵县| 沂南县| 吉木萨尔县| 台安县| 枣强县|