四、C#方法和参数
class Program
{
static void Main(string[] args)
{
int x = ;
Program p = new Program();
p.ChangeValue(x, p);
Console.WriteLine("x=" + x + ",p.count=" + p.count);
Console.ReadLine(); }
public void ChangeValue(int pValue,Program p)
{
int temp = pValue;
pValue = ;
p.number = ;
p.count = ;
p = new Program();
p.count = ; }
public int number = ;
public int count = ;
}
class Program
{
static void Main(string[] args)
{
int x = ;
Program p = new Program();
p.ChangeValue(ref x, ref p);
Console.WriteLine("x=" + x + ",p.count=" + p.count);
Console.ReadLine(); }
public void ChangeValue(ref int pValue,ref Program p)
{
int temp = pValue;
pValue = ;
p.number = ;
p.count = ;
p = new Program();
p.count = ; }
public int number = ;
public int count = ;
}
class Program
{
static void Main(string[] args)
{
string fullName;
fullName = Combine(Directory.GetCurrentDirectory(), "bin", "config", "index.html");
Console.WriteLine(fullName);
fullName = Combine(new string[] { Directory.GetCurrentDirectory(), "bin", "config", "index.html" });
Console.WriteLine(fullName);
Console.ReadLine();
}
static string Combine(params string[] paths)
{
string result = string.Empty;
foreach (string path in paths)
{
result = System.IO.Path.Combine(result, path);
}
return result;
} }
class Program
{
static void Main(string[] args)
{
string firstName = "aaaaa", middleName = "bbbbbbbbb", lastName = "cccccccc";
string fullName;
fullName = Combine(firstName);
Console.WriteLine(fullName); fullName = Combine(pfirstName: firstName,plastName:lastName);
Console.WriteLine(fullName); fullName = Combine(pfirstName: firstName, pmiddleName: middleName);
Console.WriteLine(fullName); Console.ReadLine(); }
static string Combine(string pfirstName, string pmiddleName = ".", string plastName = "")
{
string result = pfirstName + pmiddleName + plastName; return result;
} }
四、C#方法和参数的更多相关文章
- C# 本质论 第四章 方法和参数
要为方法名使用动词或动词短语 递归:递归调用方法 方法重载: try catch
- C#中方法的参数的四种类型
C#中方法的参数有四种类型: 1. 值参数类型 (不加任何修饰符,是默认的类型) 2. 引用型参数 (以ref 修饰符声明) 3. 输出型参数 (以out 修 ...
- JUC之线程池-三大方法-七大参数-四种拒绝策略
线程池:重点 三大方法 七大参数 四种拒绝策略 使用池化技术的理由: 我们的程序伴随着创建销毁线程十分浪费资源, 所以使用线程池,先创建线程,随用随取,用完归还 简单来说就是节约了资源. 使用线程池的 ...
- CLR via C#深解笔记四 - 方法、参数、属性
实例构造器和类(引用类型) 构造器(constructor)是允许将类型的实例初始化为良好状态的一种特殊方法.构造器方法在“方法定义元数据表”中始终叫.ctor. 创建一个引用类型的实例时: #1, ...
- 运行jar应用程序引用其他jar包的四种方法
转载地址:http://www.iteye.com/topic/332580 大家都知道一个java应用项目可以打包成一个jar,当然你必须指定一个拥有main函数的main class作为你这个ja ...
- Angular--页面间切换及传值的四种方法
1. 基于ui-router的页面跳转传参(1) 在AngularJS的app.js中用ui-router定义路由,比如现在有两个页面,一个页面(producers.html)放置了多个produce ...
- C#播放声音的四种方法 +AxWindowsMediaPlayer的详细用法
C#播放声音的四种方法 第一种是利用DirectX 1.安装了DirectX SDK(有9个DLL文件).这里我们只用到MicroSoft.DirectX.dll和 Microsoft.Directx ...
- PHP面向对象.__set(),__get(),__isset(),__unset()四个方法的
一般来说,总是把类的属性定义为private,这更符合现实的逻辑.但是, 对属性的读取和赋值操作是非常频繁的,因此在PHP5中,预定义了两个函数”__get()”和”__set()”来获取和赋值其属性 ...
- 【AS3】Flash与后台数据交换四种方法整理
随着Flash Player 9的普及,AS3编程也越来越多了,所以这次重新整理AS3下几种与后台数据交换方法.1.URLLoader(URLStream)2.FlashRemoting3.XMLSo ...
随机推荐
- 加载dll、lib库
2.是关于如何加载dll或lib库的.可以看这篇bog Qt调用dll中的功能函数点击打开链接 ************************************************** ...
- BZOJ 1071 [SCOI2007]组队
1071: [SCOI2007]组队 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 1330 Solved: 417[Submit][Status][ ...
- 图论(网络流):[CTSC2001]终极情报网
[CTSC2001]终极情报网 [题目描述] 在最后的诺曼底登陆战开始之前,盟军与德军的情报部门围绕着最终的登陆地点展开了一场规模空前的情报战. 这场情报战中,盟军的战术是利用那些潜伏在敌军内部的双重 ...
- 图论(生成树):HDU 5631Rikka with Graph
Rikka with Graph Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- Merge into(oracle)
作用:使用一条sql语句进行insert或者update操作,如果存在就update,如果不存在就insert 语法: MERGE INTO table_name t1 USING (table|vi ...
- Count Complete Tree Nodes ——LeetCode
Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from W ...
- mac下的改装人生——把主硬盘换成ssd
这两天搞得最多的事情就是我的这两块硬盘,基本上的时间都被他们占用去了,但是最后的结果也是让我很开心--开机瞬秒,程序瞬秒,生活质量瞬间高了很多哈. 关于ssd的各种事情,我的另外一篇博客有讲,算是比较 ...
- hdu 4424 & zoj 3659 Conquer a New Region (并查集 + 贪心)
Conquer a New Region Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- 414. Third Maximum Number
这个题有点坑啊..主要是自己蠢,以为 Integer.MIN_VALUE -1 == -2147483649 public class Solution { public int thirdMax(i ...
- ARES
ARES规划是恒生公用技术平台规划,以敏捷Agility.重用性Reused.扩展性Extend.简单性Simple为核心特性与价值取向,规划涉及ARES Server运行支撑平台.ARES Stud ...