JUST DO IT ~

          我只想當(dāng)個程序員

          out ref 作為函數(shù)的參數(shù)

          ref -----雙向傳遞 數(shù)據(jù)      ----必須是instance 好的
          out ----- 只是出來不進(jìn)去的 ,  給個引用就可以了


          a 作為ref的 傳遞進(jìn)去必須先要初始化一個 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 只需要定義一個引用

          在外面調(diào)用的地方即使  給了實例   ,進(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”

           




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


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


          網(wǎng)站導(dǎo)航:
           

          導(dǎo)航

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

          統(tǒng)計

          常用鏈接

          留言簿(3)

          隨筆分類(352)

          收藏夾(19)

          關(guān)注的blog

          手冊

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 古田县| 福鼎市| 贺兰县| 即墨市| 额敏县| 石家庄市| 石林| 湘乡市| 池州市| 兰州市| 河西区| 胶南市| 九龙坡区| 宜都市| 屯门区| 邳州市| 湖口县| 武城县| 固始县| 乐业县| 分宜县| 河源市| 河南省| 突泉县| 宁夏| 多伦县| 清镇市| 蒙阴县| 星座| 潍坊市| 灵石县| 怀化市| 孟连| 舞阳县| 汽车| 宿州市| 凤翔县| 临西县| 靖江市| 淮南市| 黄梅县|