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

9. Other Framework Types > Arguments, Revisited

Arguments, Revisited

image

Let’s do a little experiment to explore one more difference between value and reference types. Try to build the project just from the instructions, but if you run into trouble, my version is on page 302.

0 Create a new WPF project and add a button to it.

1 In the code file, define a class called Elephant within the MainWindow class. (Remember, classes can have classes as members.) Add a single auto-implemented property to Elephant called Name.

2 Add two methods to the MainWindow class (not the Elephant class). Call them both ChangeMe. The first should accept an Int32 and, in the body, increment its value. The second should accept an Elephant and change its Name property to “Sally” in the body.

3 In the button1_click event handler, create an Int32 variable and an Elephant variable. Set the Int32 to 5 and the Elephant.Name property to “George”.


  

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