Eben Coarsey
C# Exercises
10-15-2010
Quiz #1 Answers
1. True
2. A "Property"
3. The Left Side
4. It is an "instantiation"
5. A "method"
6. True
7. A "collection"
8. The "object browser"
Exercises #1
1.
2.
Workshop Answers
a. An object
b. The OS
c. The user
2. False – objects handle their own events
3. "Click"
4. Event Recursion
5. Click the control from the form designer
6. "sender"
Exercises #2
Quiz Part #2 Answers
1. False
2. True
3. a "do…while" loop
4. False
5. "break"
Exercises #3
Sestoff Exercises
C# 1.1
C#1.2
C#1.4
C#1.5
C#1.6
In the following code, I am trying to declare a read-only property Hour returning the number of hours anda read-only property Minute returning the number of minutes. For instance, new Time(23, 45).Minuteshould be 45.I need to modify the ToString() method so that it shows a Time in the format hh:mm, for instance 10:05, insteadof 605. How can I use String.Format to do the formatting in the Main() Method? using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;using System.Timers;namespace TestTime{ class Program { static void Main(string[] args) { Time timenow = new Time(1,2); Console.WriteLine("Time={0} ", timenow); Console.WriteLine("Press Any Key"); Console.ReadKey(); } public struct Time { public readonly int minutes; public Time(int hh, int mm) { Console.WriteLine("Enter Hour"); hh = Int32.Parse( Console.ReadLine()); Console.WriteLine("Enter Min"); mm = Int32.Parse( Console.ReadLine()); this.minutes = 60 * hh + mm; } public override String ToString() { return minutes.ToString(); } } }}