struct_enum
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 namespace struck
6 {
7 public enum color { red,green,blue,white,black}
8 public struct Mypoint
9 {
10 public int x;
11
12 public int y;
13 public Mypoint(int point_x,int point_y)
14 {
15 this.x = point_x+point_y;
16
17 this.y = point_y-point_x;
18 }
19
20 public static Mypoint operator +(Mypoint p1, Mypoint p2)
21 {
22 return new Mypoint (p1.x +p2.x ,p1.y +p2.y );
23 }
24
25 }
26 class Mypoint1
27 {
28 public int x=10;
29 public int y=16;
30
31 static void Main(string[] args)
32 {
33 Mypoint p = new Mypoint(20, 19);
34 Mypoint p2 = new Mypoint(100,30);
35 Mypoint p3 = new Mypoint();
36 p3 = p + p2;
37 Mypoint1 p1 = new Mypoint1();
38 p1.x = 19;
39 Console.WriteLine(p3.x+","+p3.y);//输出:98 240 这个等于先等于(130+39,69)然后(169-71,-71-169)
40 Console.WriteLine(p2.x + "," + p2.y);//130,-70
41
42 Console.WriteLine(p.x+","+p.y);//39,-1
43
44 Console.WriteLine(color.green);//输出green 实际上是个数字,另外枚举没有要实例化
45 Console.WriteLine(Convert.ToInt32(color.green));//1
46 Console.ReadLine();
47 }
48 }
49 }
50
51
posted @
2009-02-21 13:56
zxlin25
阅读(
145)
评论()
编辑
收藏
举报