四、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 ...
随机推荐
- tortoisegit安装使用
git的使用越来越广泛 使用命令比较麻烦,下面讲解一下tortoisegit的使用 先下载安装git(msysgit)和tortoisegit,安装后提示重启电脑,不解释 1.找一个文件夹做仓库 这里 ...
- 16.缓存(Cache)
如果每次进入页面的时候都查询数据库生成页面内容的话,如果访问量非常大,则网站性能会非常差.而如果只有第一次访问的时候才查询数据库生成页面内容,以后都直接输出内容,则能提高系统性能,这样无论有多少人访问 ...
- 【HDOJ】2144 Evolution
并查集+DP. /* 2144 */ #include <cstdio> #include <cstring> #include <cstdlib> #define ...
- bzoj2424
比较简单的费用流,一目了然 ; type node=record next,point,flow,cost:longint; end; ..] of node; q:..] of longint; p ...
- 网络流(最大费用最大流) :POJ 3680 Intervals
Intervals Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 7218 Accepted: 3011 Descrip ...
- 一招解决IE7无法访问https网页
很多人都遇到过这种情况: 自己的IE访问不了https的网页了,如果你百度的话,有人会告诉你注册一堆的dll文件,或者更改IE设置啦什么的.上午,我也遇到这个问题,这些方法都不管用.请教了高手,将方法 ...
- Entity Framwork db First 中 Model验证解决办法。
由于项目中用到 Entity Framwork db First 每次从数据库生成数据模型之后都会把模型更新. 只要有一个表更新.所有的类都会重新生成. 在网上找了各种例子都是差不多的, 可能 ...
- poj 2187 凸包加旋转卡壳算法
题目链接:http://poj.org/problem?id=2187 旋转卡壳算法:http://www.cppblog.com/staryjy/archive/2009/11/19/101412. ...
- 调查:Java程序员最亲睐的Web框架
这是关于Java的第二个调查,第一个调查请点这里查看. 这一次,我们要讨论的是web框架. 只有少数几种语言像Java一样提供了各种各样的web框架,上面的统计图就是一个证据.下面是其他开发者所使用w ...
- Paxos算法 Paxos Made Simple
Paxos算法 Paxos Made Simple Leslie Lamport 2001.11.1 简介 Paxos算法,纯文本方式描述,非常简单. 1 介绍 为 实现具有容错能力的分布式系统而提出 ...