四、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 ...
随机推荐
- hdu 5074 Hatsune Miku
http://acm.hdu.edu.cn/showproblem.php?pid=5074 题意:给你一个的矩阵score[i][j],然后给你一个数列,数列中有一些是-1,代表这个数可以换成1~m ...
- Struts2 实现分页
1.转自:http://www.cnblogs.com/shiyangxt/archive/2008/11/04/1316737.html环境:MyEclipse6.5+Mysql5+struts2. ...
- Unity NGUI根据高度自适应屏幕分辨率
Unity版本:4.5.1 NGUI版本:3.6.5 本文内容纯粹转载,转载保留参考链接和作者 参考链接:http://blog.csdn.net/asd237241291/article/detai ...
- bzoj3280
bzoj1221的变形版本,弄懂1221,这题还是很简单的 ; type node=record point,next,flow,cost:longint; end; ..] ...
- N-Queens II——Leetcode
Follow up for N-Queens problem. Now, instead outputting board configurations, return the total numbe ...
- SCU 4436 Easy Math 2015年四川省赛题
题目链接:http://acm.scu.edu.cn/soj/problem/4436/ 题意:给你n个整数,求这n个数的平方根和是否是一个整数: 解题思路:如果这题每个数给他算出来,必然费时间,可能 ...
- Girls' research - HDU 3294 (Manacher处理回文串)
题目大意:给以一个字符串,求出来这个字符串的最长回文串,不过这个字符串不是原串,而是转换过的,转换的原则就是先给一个字符 例如 'b' 意思就是字符把字符b转换成字符 a,那么c->b, d-& ...
- Git 的优点
1. 快速 如果你每移动一下鼠标都要等待五秒,是不是很受不了?版本控制也是一样的,每一个命令多那么几秒钟,一天下来也会浪费你不少时间.Git的操作非常快速,你可以把时间用在别的更有意义的地方. 2. ...
- Mac OS X 程序员利器 – Homebrew安装与使用
Mac OS X 程序员利器 – Homebrew安装与使用 Homebrew安装与使用 什么是Homebrew? Homebrew is the easiest and most flexible ...
- POJ 2431 Expedition (STL 优先权队列)
Expedition Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8053 Accepted: 2359 Descri ...