Section 13.11. Exercises


13.11. Exercises



Exercise 13-1

Define an interface IConvertible that indicates that the class can convert a string to C# or VB2005. The interface should have two methods : ConvertToCSharp and ConvertToVB2005 . Each method should take a string, and return a string.



Exercise 13-2

Implement that interface and test it by creating a class ProgramHelper that implements IConvertible . You can use simple string messages to simulate the conversion.



Exercise 13-3

Extend the interface by creating a new interface, IConvertible . The new interface should implement one new method, CodeCheckSyntax , which takes two strings: the string to check, and the language to use. The method should return a bool. Revise the ProgramHelper class from Exercise 13-2 to use the new interface.



Exercise 13-4

Demonstrate the use of is and as . Create a new class, ProgramConverter , that implements IConvertible . ProgramConverter should implement the ConvertToC-Sharp( ) and ConvertToVB( ) methods. Revise ProgramHelper so that it derives from ProgramConverter , and implements ICodeChecker .



Learning C# 2005
Learning C# 2005: Get Started with C# 2.0 and .NET Programming (2nd Edition)
ISBN: 0596102097
EAN: 2147483647
Year: 2004
Pages: 250

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net