1: using System;
2: using System.Collections;
3: using System.Configuration;
4: using System.Data;
5: using System.Linq;
6: using System.Web;
7: using System.Web.Security;
8: using System.Web.UI;
9: using System.Web.UI.HtmlControls;
10: using System.Web.UI.WebControls;
11: using System.Web.UI.WebControls.WebParts;
12: using System.Xml.Linq;
13:
14: namespace MCTS___Foundation
15: {
16: public partial class _Default : System.Web.UI.Page
17: {
18: protected void Page_Load(object sender, EventArgs e)
19: {
20: Cycle degrees = new Cycle(0, 360);
21: for(int i = 0; i < 6; i++)
22: {
23: degrees += 60;
24: Response.Write(degrees.Value + ", ");
25: }
26:
27: }
28: }
29:
30: public struct Cycle
31: {
32: int _val;
33: int _max ;
34: int _min;
35:
36: public Cycle(int minimum, int maximum)
37: {
38: _val = minimum;
39: _max = maximum;
40: _min = minimum;
41: }
42:
43: public int Value
44: {
45: get { return _val; }
46: set
47: {
48: if (value > _max)
49: {
50: _val = _min;
51: }
52: else if (value < _min)
53: {
54: _val = _max;
55: }
56: else
57: {
58: _val = value;
59: }
60: }
61: }
62:
63: public override string ToString()
64: {
65: return Value.ToString();
66: }
67:
68: public int ToInteger()
69: {
70: return Value;
71: }
72:
73: public static Cycle operator +(Cycle arg1, int arg2)
74: {
75: arg1.Value += arg2;
76: return arg1;
77: }
78:
79: public static Cycle operator -(Cycle arg1, int arg2)
80: {
81: arg1.Value -= arg2;
82: return arg1;
83: }
84: }
85: }