C# ref和out参数的使用
来源:互联网 发布:java list 随机排序 编辑:程序博客网 时间:2024/05/23 12:35
ref和out 参数的使用:
这两个参数的使用方法非常的简单,不过能够实际的解决一些问题。
ref这个就相当于对变量地址的引用。using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int age1 = 90;
int age2;
int age3;
AddAge(ref age1);
Console.WriteLine(age1);
AddOut(out age2,out age3);
Console.WriteLine(age2);
Console.ReadKey();
}
//ref参数的应用场景:改变外部数据的内容,进行数据的交换
static void AddAge(ref int age)
{
age++;
}
//在使用out时,一定要在函数的内部给传入的out参数赋值。在函数的内部是不能够获得
out参数外部的值
//out参数主要用在具有多个返回值的函数
static void AddOut(out int age,out int age1)
{
age = 9;
age1 = 67;
}
}
}
0 0
- C# ref和out参数的使用
- C#的out参数和ref参数
- C# 下ref和out 参数使用
- C# 下ref和out 参数使用
- 使用ref和out参数
- 使用ref和out参数
- C#总结---方法的out参数和ref参数
- C#方法中使用ref和out参数
- C#方法参数传递-同时使用ref和out关键字
- C#中的Ref参数和Out参数
- C#中out、ref、params参数的使用
- C#之高级参数 ref,out,params的使用
- c# ref参数的用法 out参数
- c# ref out 的使用
- 关于C#中的ref和out参数的说明
- C#的参数类型:params、out和ref
- C# 中ref 和out 参数的区别
- C# 方法参数params ref out 的理解和区分
- 知名的第三方开源库
- Problem C: P1053
- [leetcode-75]Sort Colors(C)
- Mavan配置
- kanban工具
- C# ref和out参数的使用
- jRTPlib支持多网卡,支持TCP
- IOS XMPP的实践
- 给图像添加探照灯效果
- 微信公众平台开发整理
- VS2002(VC7) 新建arx项目
- test
- HANA激活对象报错
- 设计模式 适配器模式