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 小高 阅读(361) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

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

统计

常用链接

留言簿(3)

随笔分类(352)

收藏夹(19)

关注的blog

手册

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜