⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 minute.cs

📁 微软系列丛书<<C#2005从入门到精通>>
💻 CS
字号:

namespace Operators
{
	struct Minute
	{
		public Minute(int initialValue)
		{
			this.value = System.Math.Abs(initialValue) % 60;
		}

		public int Value
		{
			get { return this.value; }
		}

        public static bool operator== (Minute lhs, int rhs)
        {
            return lhs.value == rhs;
        }

        public static bool operator!= (Minute lhs, int rhs)
        {
            return lhs.value != rhs;
        }

		public override bool Equals(object other)
		{
			return (other is Minute) && Equals((Minute)other);
		}

		public bool Equals(Minute other)
		{
			return this.value == other.value;
		}

		public override int GetHashCode()
		{
			return this.value;
		}

		public static Minute operator++(Minute arg)
		{
			arg.value++;
			if (arg.value == 60)
			{
				arg.value = 0;
			}
			return arg;
		}

		private int value;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -