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
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

8. Classes in the .NET Framework > Using Class Details

Using Class Details

Now lets add a property to the Ingredient class using the Class Details pane.

6 In the Class Details pane, click on <add property> in the Properties section. Type “Name”, and press the Tab key to move to the next field. By default, Visual Studio will set the property type to int.

image

Type “st” to bring up Intellisense, and set the property type to String (or string).


A Bit of Controversy

image

There’s some debate over how to name private member fields that have corresponding public properties. Because C# is case-sensitive, Microsoft recommends that you use camelCase for the field and PascalCase for the property. I don’t think that quantity and Quantity are sufficiently different, so I use an older convention, prefixing the field with “m_”, which is short for “member variable”. You’ll see both conventions in MSDN and other texts.


  

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
  • DownloadDownload
  • PrintPrint