Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

10: Defining Class Members > Partial Class Definitions

Partial Class Definitions

When you create classes with a lot of members of one type or another, things can get quite confusing, and code files can get very long. One thing that can help here, that you've looked at in earlier chapters, is to use code outlining. By defining regions in code, you can collapse and expand sections to make things easier to read. For example, you might have a class defined as follows:

public class MyClass
{
      #region Fields
      private int myInt;
      #endregion

      #region Constructor
      public MyClass()
      {
      myInt = 99;
      }
      #endregion

      #region Properties
      public int MyInt
      {
        get
        {
           return myInt;
        }

        set
        {
           myInt = value;

        }
        }
        #endregion

        #region Methods
        public void DoSomething()
        {
        // Do something...
        }
        #endregion
}

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial