|
|
其实下面的代码老外还是看得懂的,只是变量名从E文变中文了而以。
——————————————————
using System;
namespace 定义一个结构
{
public struct Location
{
public Location( int x坐标, int y坐标 )
{
x坐标值 = x坐标;
y坐标值 = y坐标;
}
public int x
{
get
{
return x坐标值;
}
set
{
x坐标值 = value;
}
}
public int y
{
get
{
return y坐标值;
}
set
{
y坐标值 = value;
}
}
public override string ToString()
{
return String.Format( "{0}, {1}", x坐标值, y坐标值 );
}
private int x坐标值;
private int y坐标值;
}
/// <summary>
/// 练习 的摘要说明。
/// </summary>
class 练习
{
public void 我的函数( Location 位置 )
{
位置.x = 50;
位置.y = 100;
Console.WriteLine( "在\'我的函数里\'位置坐标是:{0}", 位置 );
}
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
Location 一个位置 = new Location( 200, 300 );
Console.WriteLine( "位置坐标是:{0}", 一个位置 );
练习 t = new 练习();
t.我的函数( 一个位置 );
Console.WriteLine( "位置坐标是:{0}", 一个位置 );
}
}
}
|
|