using System;
using System.Collections.Generic;
using System.Text;
namespace Queue
{
public struct Point//定义结构
{
public int x;
public int y;
//结构中无法定义参数的构造函数
//public Point() {
//}
public Point(int p1, int p2)//方法
{
x = p1;
y = p2;
}
}
class Test
{
static void Main(string[] args)
{
////第一种、通过new 关键字创建对象
//Point p1 = new Point();
//Point p2 = new Point(10,10);
//System.Console.Write("Point 1: ");
//System.Console.WriteLine("x={0},y={1}", p1.x, p1.y);
//System.Console.Write("Point 2: ");
//System.Console.WriteLine("x={0},y={1}", p2.x, p2.y);
//Console.ReadLine();
////输出:
////Point 1: x=0,y=0
////Point 2: x=10,y=10
//第二种、定义数据对象
Point p1;
p1.x = 10;
p1.y = 20;
System.Console.Write("point 1:");
System.Console.WriteLine("x={0};y={1}",p1.x,p1.y);
Console.ReadLine();
//输出:
//point 1: x=10,y=20
}
}
}