Dave
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace HowToCreateUDTs { class Program { static void Main(string[] args) { Cycle degrees = new Cycle(0, 359); for(int i = 0; i <= 8; i++) { degrees += 90; Console.WriteLine("degrees = {0}", degrees); } } } struct Cycle { // private fields int _val, _min, _max; // constructor public Cycle(int min, int max) { _val = min; _min = min; _max = max; } public int Value { get { return _val; } set { if (value > _max) this.Value = value - _max + _min - 1; else { if (value < _max) this.Value = _min - value + _max - 1; else _val = value; } } } public override string ToString() { return Value.ToString(); } public int ToInteger() { return Value; } public static Cycle operator +(Cycle arg1, int arg2) { arg1.Value += arg2; return arg1; } public static Cycle operator -(Cycle arg1, int arg2) { arg1.Value -= arg2; return arg1; } } }