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

📄 portrange.cs

📁 pureIRCd是一个用c语音写的irc(RFC459)服务,可以给您带来很多的方便
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;

namespace SDP
{
    /// <summary>
    /// This class describes a range of ports.
    /// </summary>
    public class PortRange
    {
        private ushort port;
        /// <summary>
        /// Gets or sets the value of the starting port.
        /// </summary>
        public ushort Port
        {
            get { return this.port; }
            set { this.port = value; }
        }

        private ushort numberOfPorts;
        /// <summary>
        /// Gets or sets the number of ports in the range.
        /// </summary>
        public ushort NumberOfPorts
        {
            get { return this.numberOfPorts; }
            set
            {
                if (value <= 0) throw new ArgumentException("The number of ports must be greater than or equal to one.");
                if (this.port + value - 1 > 65535) throw new OverflowException("This number of ports causes the end of the port range to be invalid.");
                this.numberOfPorts = value;
            }
        }

        /// <summary>
        /// Instantiates a new PortRange.
        /// </summary>
        /// <param name="port">The starting port. The default number of ports is one, so this
        /// range is effectively one port.</param>
        public PortRange(ushort port) : this(port, 1) { }

        /// <summary>
        /// Instantiates a new PortRange.
        /// </summary>
        /// <param name="port">The starting port.</param>
        /// <param name="numberOfPorts">The number of ports in the range. This value must
        /// be greater than or equal to one.</param>
        public PortRange(ushort port, ushort numberOfPorts)
        {
            this.Port = port;
            this.NumberOfPorts = numberOfPorts;
        }

        /// <summary>
        /// Converts this PortRange to its string representation.
        /// </summary>
        /// <returns>A string.</returns>
        public override string ToString()
        {
            string s = this.port.ToString();
            if (this.numberOfPorts == 1) return s;
            return s + "/" + this.numberOfPorts.ToString();
        }
    }
}

⌨️ 快捷键说明

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