czC#02
1、out参数
out参数要求在方法的内部必须为其赋值
using System;
using System.Text; namespace Demo
{ class Program
{
//返回一个数组的最大值,最小值,均值,长度,名称 static void Main()
{
int max = ;
int min = ;
int ave = ;
int len = ;
string name = "";
int[] arr = { , , };
Test(arr, out max, out min, out ave, out len, out name);
Console.WriteLine(max);
Console.WriteLine(min);
Console.WriteLine(ave);
Console.WriteLine(len);
Console.WriteLine(name);
Console.ReadLine(); } public static void Test(int[] arr,out int max, out int min, out int ave, out int len, out string name)
{
//伪代码
max = ;
min = ;
ave = ;
len = ;
name = "arr";
}
} }
2、ref参数
值传递时,原值也会改变
using System;
using System.Text; namespace Demo
{ class Program
{ static void Main()
{
int num = ;
Test(ref num);
Console.WriteLine(num);
Console.ReadLine(); } public static void Test(ref int num)
{
num += ;
}
} }
3. params可变参数
参数列表变为数组,方法执行时数组内的元素不可改变
using System;
using System.Text; namespace Demo
{ class Program
{ static void Main()
{
Console.WriteLine(Test("Linda", , , , ));
Console.ReadLine(); } public static int Test(string name,params int[] score)
{
return score[];
}
} }
czC#02的更多相关文章
- Kotlin中变量不同于Java: var 对val(KAD 02)
原文标题:Variables in Kotlin, differences with Java. var vs val (KAD 02) 作者:Antonio Leiva 时间:Nov 28, 201 ...
- Android游戏开发实践(1)之NDK与JNI开发02
Android游戏开发实践(1)之NDK与JNI开发02 承接上篇Android游戏开发实践(1)之NDK与JNI开发01分享完JNI的基础和简要开发流程之后,再来分享下在Android环境下的JNI ...
- iOS系列 基础篇 02 StoryBoard 故事板文件
iOS基础 02 StoryBoard 故事板文件 目录: 1. 故事板的导航特点 2. 故事板中的Scene和Segue 3. 本文最后 在上篇HelloWorld工程中有一个Main.storyb ...
- [转]Tesseract 3.02中文字库训练
下载chi_sim.traindata字库下载tesseract-ocr-setup-3.02.02.exe 下载地址:http://code.google.com/p/tesseract-ocr/d ...
- Java多线程系列--“JUC锁”02之 互斥锁ReentrantLock
本章对ReentrantLock包进行基本介绍,这一章主要对ReentrantLock进行概括性的介绍,内容包括:ReentrantLock介绍ReentrantLock函数列表ReentrantLo ...
- Oracle Recovery 02 - 常规恢复之不完全恢复
背景:这里提到的常规恢复指的是数据库有完备可用的RMAN物理备份. 实验环境:RHEL6.4 + Oracle 11.2.0.4 单实例. 二.常规恢复之不完全恢复:部分数据丢失 2.1 重做日志文件 ...
- 异步编程系列第02章 你有什么理由使用Async异步编程
p { display: block; margin: 3px 0 0 0; } --> 写在前面 在学异步,有位园友推荐了<async in C#5.0>,没找到中文版,恰巧也想提 ...
- star ccm+ 11.02安装
STAR CCM+是CD-Adapco公司的主打软件,其安装方式较为简单,这里以图文方式详细描述STAR CCM+11.02安装过程. 1 安装准备工作2 正式安装3 软件破解4 软件测试 1 安装准 ...
- 导入项目时,有关[2016-04-03 20:38:02 - Dex Loader] Unable to execute dex: Multiple dex files 问题
最近我在学习androidUI设计,在网上找了一个UI菜单界面开源代码示例,按照步骤导入项目,运行的时候控制台结果报了如下错误: [2016-04-03 20:38:02 - Dex Loader] ...
随机推荐
- 基于rtmp的移动端推流解决方案
因工作需要,及考虑成本因素,需要探索一套免费的移动端基于rtmp推流的直播解决方案,过程虽稍显曲折,但最终还是完成了目标.在这里将记录下来,以便日后查阅. 总体思路 移动端推流(RTMP) ---&g ...
- Shell遍历目前下后缀名为.xml的文件并替换文件内容
1.shell查找 .xml文件 find /home/esoon/test/external/ -type f -name '*.xml' 2.替换方法 sed -i "s/10.111. ...
- Python_实战爬虫
# -*- coding: utf-8 -*-__auther__ = "jiachaojun"__time__ = '2020/1/12 11:03'import request ...
- 使用okhttp连接网络,再把数据储存进Sqlite
这次会把所有之前学过的东西应用在一起,写一个登入的功能. 1. Activity调用CONFIG,获得URL后 2. Activity再调用Okhttp,从服务器返回JSON 3. Activity调 ...
- 基础篇七:默认配置语法(/etc/nginx/nginx.conf)
首选我们 vim nginx.conf 参照上图,我们看看nginx.conf 的个参数含义 我们再看看 /etc/nginx/conf.d/default.conf
- [LC] 659. Split Array into Consecutive Subsequences
Given an array nums sorted in ascending order, return true if and only if you can split it into 1 or ...
- 21)PHP,杨辉三角
代码展示: $n=; ;$i<=$n;$i++){ ;$k<=$i;$k++){ ||$k==$i){ $arr[$i][$k]=; }else{ ){ $arr[$i][$k] = $a ...
- PHP验证电子邮件-密码保护和随机密码
验证邮箱: function isValidEmail($email){ return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a ...
- hdu 2586 How far away ?(LCA模板)(倍增法)
在dfs的过程中维护三个数组: deep[i],表示i点在树中的深度: grand[x][i],表示x的第2^i个祖先的节点编号: dis[x][i],表示x到它2^i祖 #include<io ...
- k8s中command、args和dockerfile中的entrypoint、cmd之间的关系
当用户同时写了command和args的时候自然是可以覆盖DockerFile中ENTRYPOINT的命令行和参数,那么对于具体情况呢,比如仅仅写了command或者args的时候呢?完整的情况分类如 ...