c#基础练习:c#基础--03 参数中的 ref和out (03版)
发布时间
阅读量:
阅读量
从程序结构上来说,ref和out是把return的工作给抢了。
using System;
namespace ref和out
{
class Program
{
static void Main(string[] args)
{
int m = 10;
int n = 15;
int max= Max(m, n);
Console.WriteLine("return最大值为:{0}",max);
Max(m, n, out max);
Console.WriteLine("out最大值为:{0}",max);
Maxref(m, n, ref max);
Console.WriteLine("ref最大值为:{0}",max);
Console.Read();
}
static int Max(int a,int b)
{
return a>b? a : b
全部评论 (0)
还没有任何评论哟~
