using System;
namespace prg1
{
class Paramstest
{
//值参数使用演示
public static void Transposition_1(int a, int b)
{
int temp = a;
a = b;
b = temp;
}
//引用参数使用演示
static void Transposition_2(ref int a,ref int b)
{
int temp = a;
a = b;
b = temp;
}
static void Main(string[] args)
{
int a = 25;
int b = 30;
//调用Transposition_1
Console.WriteLine("调用Transposition_1之前a={0},b={1}",a,b);
Transposition_1(a,b);
Console.WriteLine("调用Transposition_1之后a={0},b={1}", a, b);
Console.WriteLine("====================\n");
//调用Transposition_2
Console.WriteLine("调用Transposition_2之前a={0},b={1}", a, b);
Transposition_2(ref a,ref b);
Console.WriteLine("调用Transposition_2之后a={0},b={1}", a, b);
Console.WriteLine("====================\n");
Console.ReadKey();
}
}
}
static void Transposition_2(ref int a,ref int b)
{
int temp = a;
a = b;
b = temp;
}
//Use of output parameters
static void Transposition_3(string name,out string FistName,out string LastName)
{
int i=name.Length;//Get the length of the string
while(i>0)
{
char chparm=name[i-1];
if (chparm == '.')
{
break;
}
i--;
}
FistName = name.Substring(0,i-1);
LastName = name.Substring(i);
}
//调用Transposition_3
string DoName,Nmark;
Transposition_3("rohelm.X",out DoName,out Nmark);
Console.WriteLine("Domain Name of Myself: {0}",DoName);
Console.WriteLine("The last name of my Domain Name: {0}",Nmark);
class Prmarry
{
public static void Show(params string[] name)
{
Console.WriteLine("Array contains the number of elements: {0}", name.Length);
Console.Write("elements of NameArray:");
for (int i = 0; i < name.Length; i++)
{
Console.Write("{0,10}",name[i]);
}
}
}
//调用Show
string[] NameArray = { "rohelm.X", "Boolean", "rrats" };
Prmarry.Show(NameArray);
Console.ReadKey();
using System;
namespace prg1
{
class Paramstest
{
//值参数使用演示
public static void Transposition_1(int a, int b)
{
int temp = a;
a = b;
b = temp;
}
//引用参数使用演示
static void Transposition_2(ref int a,ref int b)
{
int temp = a;
a = b;
b = temp;
}
//Use of output parameters
static void Transposition_3(string name,out string FistName,out string LastName)
{
int i=name.Length;//Get the length of the string
while(i>0)
{
char chparm=name[i-1];
if (chparm == '.')
{
break;
}
i--;
}
FistName = name.Substring(0, i - 1);
LastName = name.Substring(i);
}
static void Main(string[] args)
{
int a = 25;
int b = 30;
//调用Transposition_1
Console.WriteLine("调用Transposition_1之前a={0},b={1}",a,b);
Transposition_1(a,b);
Console.WriteLine("调用Transposition_1之后a={0},b={1}", a, b);
Console.WriteLine("====================\n");
//调用Transposition_2
Console.WriteLine("调用Transposition_2之前a={0},b={1}", a, b);
Transposition_2(ref a,ref b);
Console.WriteLine("调用Transposition_2之后a={0},b={1}", a, b);
Console.WriteLine("====================\n");
//调用Transposition_3
string DoName,Nmark;
Transposition_3("rohelm.X",out DoName,out Nmark);
Console.WriteLine("Domain Name of Myself: {0}",DoName);
Console.WriteLine("The last name of my Domain Name: {0}"+"\n",Nmark);
//调用Show
string[] NameArray = { "rohelm.X", "Boolean", "rrats" };
Prmarry.Show(NameArray);
Console.ReadKey();
}
}
class Prmarry
{
public static void Show(params string[] name)
{
Console.WriteLine("Array contains the number of elements: {0}", name.Length);
Console.Write("elements of NameArray:");
for (int i = 0; i < name.Length; i++)
{
Console.Write("{0,10}",name[i]);
}
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有