四、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 ...
随机推荐
- 使用 getNextException() 来检索已经过批处理的特定元素的异常。 ERRORCODE=-4228, SQLSTATE=null
今天查询了一天发现的问题,用ibatis做批量操作时,报错: [非原子批处理出现故障]使用 getNextException() 来检索已经过批处理的特定元素的异常. ERRORCODE=-4228, ...
- sudo and su
sudo bash : change the current user into root su u1: change the current user into u1 useradd: add ne ...
- AC自动机(Aho-Corasick automation)模板 HDU:2222
#include <iostream> #include <cstdio> #include <cstring> #include <queue> us ...
- C语言赋值运算符
赋值运算符: 分类: 简单赋值 int a ; a=10; 复合运算符 int a ; a+=4; 复合位运算符 int a; a&=1:
- 分布式锁 基于Redis
分布式锁的实现(基于Redis) 参考:http://www.jb51.net/article/75439.htm http://www.linuxidc.com/Linux/2015-01/1118 ...
- SCOI2015酱油记
Orz怒跪ns高一进A队,常规还是年级rank1,把gerw都下了一跳. Day1还是拿了点分的,调了半天T3终于调出来了(果然xlk大神可信),加上T1暴力有120(跟爆蛋有什么区别).T1大概有2 ...
- 查看Oracle最耗时的SQL
有很多种方法可以用来找出哪些SQL语句需要优化,但是很久以来,最简单的方法都是分析保存在V$SQL视图中的缓存的SQL信息.通过V$SQL视图,可以确定具有高消耗时间.CUP和IO读取的SQL语句. ...
- solr ,hadoop ,lucene,nutch 的关系和区别
apache lucene是apache下一个著名的开源搜索引擎内核,基于Java技术,处理索引,拼写检查,点击高亮和其他分析,分词等技术. nutch和solr原来都是lucene下的子项目.但后来 ...
- [置顶] 步步辨析JS中的对象成员
前提 首先我们应该明白创建一个JS对象的具体实例是实例化的过程,而实例化是通过new关键字实现的,这个对象是含有constructor的,一般的核心对象都会具有constructor以便创建其实例.因 ...
- [Javascript] String method: endsWith() && startsWith()
With endsWith && startsWith, you can easily find out whether the string ends or starts with ...