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

8. Classes in the .NET Framework > Adding State Members

Adding State Members

Now that we have our classes set up, it’s time to start adding some members to them. We’ll start with the Ingredient class. You can add class members in the Diagram pane or the Class Details pane of the Class Designer. I find it easier to use the Class Details pane, but let’s try the Diagram pane so you can decide for yourself.

5 Right-click the Ingredient class in the Diagram pane and choose Add, Field. Visual Studio will add the field to both the diagram and the Class Details pane.

Change the name of the field to m_quantityOnHand.

image

You’ll see in the Class Details pane that Visual Studio has set the field to its default values, an int (which, you’ll recall, is a .NET Framework Int32) with private accessibility. That’s what we need here, so you don’t need to change anything.


  

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


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint