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

Exercises

  1. Write code that defines a base class, MyClass, with the virtual method GetString(). This method should return the string stored in the protected field myString, accessible through the write-only public property ContainedString.
  2. Derive a class, MyDerivedClass, from MyClass. Override the GetString() method to return the string from the base class, using the base implementation of the method, but add the text “(output from derived class)” to the returned string.
  3. Write a class called MyCopyableClass that is capable of returning a copy of itself using the method GetCopy(). This method should use the MemberwiseClone() method inherited from System.Object. Add a simple property to the class, and write client code that uses the class to check that everything is working.

  

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