在C#中,#region的作用

#region和#endregion指令用于把一段代码标记为有给定名称的一个块,从而使代码在屏幕上更好地布局。例如:

     /// <summary>
    /// Parses one line in a GEDCOM file.
    /// </summary>
    class GedcomLine
    {
        #region fields

        // Parts of the GEDCOM line.
        private int level;
        private string tag;
        private string data;

        // Expression pattern used to parse the GEDCOM line.
        private readonly Regex regSplit = new Regex(
            @"(?<level>\d+)\s+(?<tag>[\S]+)(\s+(?<data>.+))?");

        // Expression pattern used to clean up the GEDCOM line.
        // Only allow viewable characters.
        private readonly Regex regClean = new Regex(@"[^\x20-\x7e]");

        // Expression pattern used to clean up the GEDCOM tag.
        // Tag can contain alphanumeric characters, _, ., or -.
        private readonly Regex regTag = new Regex(@"[^\w.-]");

        #endregion

        #region properties

        /// <summary>
        /// Level of the tag.
        /// </summary>
        public int Level
        {
            get { return this.level; }
            set { this.level = value; }
        }

        /// <summary>
        /// Line tag.
        /// </summary>
        public string Tag
        {
            get { return this.tag; }
            set { this.tag = value; }
        }

        /// <summary>
        /// Data of the tag.
        /// </summary>
        public string Data
        {
            get { return this.data; }
            set { this.data = value; }
        }

        #endregion

        .

        .

        .

    }

在VS编辑视图下就可以缩小为:

     /// <summary>
    /// Parses one line in a GEDCOM file.
    /// </summary>
    class GedcomLine
    { 

        fields

        properties

        .

        .

        .

    }


http://blog.sina.com.cn/s/blog_5d0279370100b6ep.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值