Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By Tolls

Thread: Same keyword #region in C#

  1. #1
    hqt
    hqt is offline Member
    Join Date
    Nov 2011
    Posts
    27
    Rep Power
    0

    Question Same keyword #region in C#

    In C#, there is a useful keyword named #region. (Maybe this keyword not in C#, it just be defined by IDE Visual Studio).
    Purpose of this keyword is lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Editor.
    for example:
    Java Code:
    #region this is example
    //command A
    //command B
    #endregion
    So, above code is a block and I can collapse it for short view. (like you often do for a function).

    this way is useful for a long code. But I don't know what keyword same like this in Java (or in Java IDE ? I'm using IDEA and NetBean).

    thanks for help :)

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: Same keyword #region in C#

    That's entirely down to the Visual Studio IDE I think.
    Eclipse has little '-' and '+' buttons in the left side gutter (as do other Java IDEs) that allow you to compact methods and javadoc comments.

  3. #3
    hqt
    hqt is offline Member
    Join Date
    Nov 2011
    Posts
    27
    Rep Power
    0

    Default Re: Same keyword #region in C#

    Yes, but for example. When you use Getter/Setter for a class. It's too long and not necessary to show. And you don't want to click '+' many times. So you just use: (in VS):
    Java Code:
    #region Getter/Setter
    //code for Getter and Setter here
    #endregion
    And after that, you just press '+' once time. It's faster and less bored. And I don't know how to do the same in Java.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: Same keyword #region in C#

    You can't.
    Pointless IDE-related splurge in your code, frankly.

    If you don't want to see your getters and setters then stick them as the last methods in your class and just don't scroll down to them.
    DarrylBurke likes this.

Similar Threads

  1. Region and Language problem in Joption
    By rjain in forum New To Java
    Replies: 0
    Last Post: 11-04-2011, 11:19 AM
  2. Replace a region of an image
    By alex88 in forum Java 2D
    Replies: 4
    Last Post: 06-04-2011, 05:21 PM
  3. Multiple JButtons in BorderLayout region.
    By VisionIncision in forum AWT / Swing
    Replies: 3
    Last Post: 01-02-2011, 11:28 PM
  4. Change color of a region
    By sky in forum AWT / Swing
    Replies: 5
    Last Post: 11-24-2009, 03:47 PM
  5. Use of this keyword
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-18-2007, 07:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •