ref参数
来源:互联网 发布:php获取时间轴 编辑:程序博客网 时间:2024/06/15 05:17
能够将一个变量带入一个方法中进行改变,改变完成后,再讲改变后的值带出方法。
ref参数要求在方法外必须为其赋值,而方法内可以不赋值。
class Program { static void Main(string[] args) { double salary = 5000; JiangJin(ref salary); Console.WriteLine(salary); Console.ReadKey(); } public static void JiangJin(ref double s) { s += 500; } public static void FaKuan(double s) { s -= 500; } }
class Program { static void Main(string[] args) { //使用方法来交换两个int类型的变量 int n1 = 10; int n2 = 20; //int temp = n1; //n1 = n2; //n2 = temp; Test(ref n1, ref n2); Console.WriteLine(n1); Console.WriteLine(n2); Console.ReadKey(); //n1 = n1 - n2;//-10 20 //n2 = n1 + n2;//-10 10 //n1 = n2 - n1;//20 10 } public static void Test(ref int n1, ref int n2) { int temp = n1; n1 = n2; n2 = temp; } }
0 0
- ref参数
- ref参数
- ref和out参数
- out 和ref参数
- ref 与 out 参数
- c# ref参数使用
- 参数关键字out,ref
- C# 参数关键字ref
- ref out 参数传递
- C# ref参数问题
- Out和Ref参数
- 数组类型 ref参数
- c#之ref参数
- C# ref参数
- params out ref 参数
- C#基础---ref参数
- ref 参数与 out 参数
- ref 参数与 out 参数
- Hadoop本地库
- 一共81个,开源大数据处理工具汇总(下),包括日志收集系统/集群管理/RPC等
- SSH:Hibernate框架(Hibernate复合主键映射)
- 各种功能网站合集
- 核心动画
- ref参数
- 通过URLHttpConnection方式连接网络步骤,获取位图为例
- mahout on hadoop2 实践
- PJSIP注册过程中保持VIA头域sent-by(发送原地址)不变
- 关于PopupWindow的简单说明
- 15.1 DIB 文件格式
- 删除已有数组元素
- 通过URLHttpConnection方式来取得图片,并且显示在ImageView上
- CCActionEase(2)