Thursday, March 21, 2013

Using #Region in Dot Net


The #region directive allows organizing code files. Using #region directive we can separate the code. We can create separate region for each code block. Means to declare the variables, constants, functions etc we can use different code block by separating using #region directive.

Here is the example-

// region 1
#region Public Variables
Public int value1
Public int value2
#endregion

//region 2
#region Methods
public string  GetData()
{
--------
--------
}
#endregion


in above example we can see that I have created 2 region.

region1 for Public variables
region2 for methods


Like this we can create other regions also.


There are some benefits of using #region directive.

1. Separation of code
2. Readability
3. Easy to maintain
4. Easy to expand or collapse the code block
5. Easy to move entire code block


It is good to use #region directive while doing coding.



Thanks



1 comment:

  1. Casino Sites that Accept Crypto (2021)
    We 인천 휴게텔 list 통장 협박 대처법 the w88 com login best crypto 플레이 포커 casinos accepting BTC and Ethereum. Discover everything you need to know about cryptocurrencies and how to start playing now.🎲 All casinos with Bitcoin: LeoVegas💻 Live Casino: Videoslots🎲 999betasia Number of Slots: 300+

    ReplyDelete