📄 ex-07-01
字号:
//Example 07-01: Creating a struct
using System;
public struct Location
{
public Location(int xCoordinate, int yCoordinate)
{
xVal = xCoordinate;
yVal = yCoordinate;
}
public int x
{
get
{
return xVal;
}
set
{
xVal = value;
}
}
public int y
{
get
{
return yVal;
}
set
{
yVal = value;
}
}
public override string ToString()
{
return (String.Format("{0}, {1}", xVal,yVal));
}
private int xVal;
private int yVal;
}
public class Tester
{
public void myFunc(Location loc)
{
loc.x = 50;
loc.y = 100;
Console.WriteLine("Loc1 location: {0}", loc);
}
static void Main()
{
Location loc1 = new Location(200,300);
Console.WriteLine("Loc1 location: {0}", loc1);
Tester t = new Tester();
t.myFunc(loc1);
Console.WriteLine("Loc1 location: {0}", loc1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -