C#中out的使用和数组型参数
来源:互联网 发布:淘宝话术技巧 编辑:程序博客网 时间:2024/05/23 12:24
//数组型参数
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
int max, min, total;
total = MyClass.GetMaxMinSum(out max, out min, 23, 7, 48, 19);
Console.WriteLine("max={0},min={1},sum={2}",max,min,total);
int[] a = { 1, 2, 3, 4, 5, 6 };
total = MyClass.GetMaxMinSum(out max,out min, a);
Console.WriteLine("max={0},min={1},sum={2}", max, min, total);
Console.ReadKey();
}
}
class MyClass
{
public static int GetMaxMinSum(out int max, out int min, params int[] a)
{
max = min = a[0];
int sum = 0;
for (int i = 0; i < a.Length; i++)
{
if (a[i] > max)
max = a[i];
if (a[i] < min)
min = a[i];
sum += a[i];
}
return sum;
}
}
}
- C#中out的使用和数组型参数
- C#中使用ref和out传递数组的方法
- c#中方法out参数的使用
- C# ref和out参数的使用
- C#方法中使用ref和out参数
- C#中使用 ref 和 out 传递数组
- c#中ref和out参数使用时需要注意的问题
- c#中ref和out参数使用时需要注意的问题
- C#中ref和out参数使用时需要注意的问题
- C#中out、ref、params参数的使用
- C# 中ref 和out 参数的区别
- C#中 ref 和 out 参数的区别
- C#的out参数和ref参数
- C# 下ref和out 参数使用
- C# 下ref和out 参数使用
- c#使用 ref 和 out 传递数组
- c# ---使用 ref 和 out 传递数组
- C#高级参数out的使用
- 一环境搭建
- Android开发概要记录
- idea快捷键使用
- Android自定义星星评分控件
- mongo 增加索引
- C#中out的使用和数组型参数
- 【面试题】剑指Offer-18-判断一颗树是否为另一颗树的子树
- eclipse工程转到androidstudio中
- 简单的图文混排功能
- 关于Structs中ActionForm的日期格式的转换
- LeetCode--Number Complement
- python学习语法
- finally中使用return会吃掉catch中抛出的异常&finally中抛出的异常会吃掉catch中的return
- solr系列二:solr导入数据库数据