四、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 ...
随机推荐
- DB2中时间格式化
values to_char(current timestamp - 7 hours,'hh24')||'点' values varchar(hour(current time + 5 hour))| ...
- 通用GPIO模拟串口,提供源代码,本人经过测试OK(第一版)
--------------------------serial.h------------------------------------------ #ifndef _SERIAL_H_ #def ...
- Hadoop环境搭建-入门伪分布式配置(Mac OS,0.21.0,Eclipse 3.6)
http://www.linuxidc.com/Linux/2012-10/71900p2.htm http://andy-ghg.iteye.com/blog/1165453 为Mac的MyEcli ...
- 【HDOJ】2757 Ocean Currents
简单BFS. /* 2757 */ #include <iostream> #include <queue> #include <cstdio> #include ...
- Linux&shell 之基本Shell命令
写在前面:案例.常用.归类.解释说明.(By Jim) 文件和目录列表lsls -F (用斜杠区分目录和文件)ls -a (把隐藏文件一并显示出来)ls -l (同ll,显示详细信息)ls -l 文件 ...
- Farm Irrigation(并查集)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...
- Remove Duplicates from Sorted List II ——LeetCode
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numb ...
- [Locked] Two Sum
Two Sum II - Input array is sorted Given an array of integers that is already sorted in ascending or ...
- 356. Line Reflection
首先找到X方向的中点,如果中点是一个点,那么分别从这个点开始往左右找就行:如果是一个区间,比如1 2之间,那么首先总点数得是偶数,然后以1和2往左右两边找就行.. 找的时候,有3种情况: 同时没找到, ...
- 软件设计模式 B卷
软件设计模式 试 卷(作业考核 线上) B 卷 学习中心: 院校学号: 姓名 (共 页 ...