Exercises


  1. The following two functions have errors. What are they?

     static bool Write() { Console.WriteLine("Text output from function."); } static void myFunction(string label, params int[] args, bool showLabel) { if (showLabel) Console.WriteLine(label); foreach (int i in args) Console.WriteLine("{0}", i); } 

  2. Write an application that uses two command-line arguments to place values into a string and an integer variable, respectively. Then display these values.

  3. Create a delegate and use it to impersonate the Console.ReadLine() function when asking for user input.

  4. Modify the following struct to include a function that returns the total price of an order:

     struct order { public string itemName; public int    unitCount; public double unitCost; } 
  5. Add another function to the order struct that returns a formatted string as follows, where italic entries enclosed in angle brackets are replaced by appropriate values:

     Order Information: <unit count> <item name> items at $<unit cost> each, total cost $<total cost> 




Beginning Visual C# 2005
Beginning Visual C#supAND#174;/sup 2005
ISBN: B000N7ETVG
EAN: N/A
Year: 2005
Pages: 278

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