5.5. Exercises

  1. Explain the difference between a reference variable and a value type variable.

  2. Suppose you have a long message that you wrote and stored in a string named message. You have this nagging feeling that you misspelled Friday as Frday somewhere in the string. Write the statement(s) that would find and correct the misspelling.

  3. I mentioned that there is an error in the program that uses the Remove() method. The problem is that after the word is removed there are two spaces between the remaining words. How would you fix this bug?

  4. What is a constructor and when should it be used?

  5. Suppose the user typed her birthday into a textbox named txtBirthday in the form MM/DD/YY and you want to show how old she is in a textbox named txtAge. What would the code look like?

Get Beginning C# 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.