C# ref out
来源:互联网 发布:js webkittransition 编辑:程序博客网 时间:2024/06/07 04:50
ref 关键字使参数按引用传递。其效果是,当控制权传递回调用方法时,在方法中对参数所做的任何更改都将反映在该变量中。
class testref
{
private testint(int i)
{
i = 50;
}
private testrefint(ref int i)
{
i = 50;
}
private testoutint(out int i);
{
i = 50;
}
private test()
{
int itest = 1;testint(itest); //结果为itest =1
int itest = 1;testrefint(itest); //结果为itest =50
int itest = 1;testoutint(itest); //结果为itest =50int itest ; testrefint(itest); //报错 必须初始化int iitest ;testoutint(itest); //正确不须初始化
}
}
class testref
{
private testint(int i)
{
i = 50;
}
private testrefint(ref int i)
{
i = 50;
}
private testoutint(out int i);
{
i = 50;
}
private test()
{
int itest = 1;testint(itest); //结果为itest =1
int itest = 1;testrefint(itest); //结果为itest =50
int itest = 1;testoutint(itest); //结果为itest =50int itest ; testrefint(itest); //报错 必须初始化int iitest ;testoutint(itest); //正确不须初始化
}
}
- C# ref and out
- c# out ref 使用
- C# params,ref,out
- c#中的ref out
- C# ref out
- C# ref out
- C# ref/out 關鍵字與傳遞參考型別參數
- C# out和ref
- C# ref和out
- C# ref out params
- C# 引用ref/out
- C# out和ref
- c# ref out 区别
- c# ref与out
- c# out与ref
- C#中的 ref 和 out
- C# ref和out关键字
- c# ref 和 out 差异
- .net 面试题
- OOAD与UML笔记
- log4cplus
- “发送至Onenote”惹来的小麻烦
- div + css 学习总结
- C# ref out
- 安装完QQ必须要删除掉的几个恐怖文件
- UITextField 文本字段控件 -- IOS (解决键盘遮住View及密文設定的问题)(实例)
- 解读ExpandableListView源码样式
- 设计公共API的六个注意事项
- 如何在 Xcode 4.2 之后建立WindowBased Application
- attribute 用法 section 部分
- Oracle 9i for linux
- POJ——2506(找规律加大数乘法 )