To Jost .NWDP Site

C#-2 Notes

Review Questions

  1. What is wrong with this statement?

  2. How do you check whether a string represents a number?

  3. More than one control can be attached to an event handler. How can you get the VS IDE to do this?

  4. What are the default events for these controls
     

  5. What are the Enter and Leave events?

  6. How do you determine the order that controls on an ASP.Net web page receive the focus when the tab key is repeatedly pressed?

  7. How are each of these properties used in ASP.Net projects?

  8. On an .aspx page, how do you avoid using delegates to connect events with their event handlers?

  9. What is wrong with this web control tag?

  10. How can you avoid the need to upload the DLL for the code behind to the server for an .aspx page?

 

Examples

Strings  SSBComparison  Vehicle1  Vehicle2  Vehicle3  Vehicle4  Vector1  FileIO1  ArrayListCol  VehicleArray  VehicleCol  Employee  Virtual  Abstract  Brushes  TryCatch
 
Example files: cs2.zip and cs2.txt.

 

Part A: Topics from Event Driven Programming Notes

  1. Controls as Classes   Events.WinformsEvents Example

  2. Exercise:  Create an ASP.Net example with a page that contains these controls: LinkButton and Calendar

 

Part B: The String and StringBuilder Classes

  1. String Manipulation Methods   Strings Example

  2. The StringBuilder Object   SSBComparison Example

 

Part C: Class Diagrams

 

Part D: Using Classes and Objects

  1. User Defined Classes

     

  2. Constructors   Vector1 Example

 

Part E:   File Input and Output.

  1. Using the System.IO Methods   FileIO1, EventDriven.ShowPoem, Misc.CurrRateFromWeb Examples

 

Part F:   Collections of Objects

  1. ArrayList Collections   ArrayListCol Example

  2. Advantages of an ArrayList Collection over an Array

  3. An Array of Objects   VehicleArray Example

    • The VehicleArray Example inserts objects into an array and prints only the objects in the array that are not null.

  4. A Collection of Objects   VehicleCol Example

    • An ArrayList collection contains objects of type object.

    • A value type object is boxed (stored on the heap) when it is added to the collection.

    • An object is unboxed when it is cast back and assigned to a value type variable.

    • Here is simpler example of boxing. Memory for the object y is allocated on the heap, but y is tagged as a value type object of type int.
      int x = 5;
      object y = x;

    • Now let's unbox y. Memory for z is allocated on the stack.
      int z = (int) y;

    • Extensive use of boxing and unboxing can cause performance problems.

    • Use generic collections to avoid boxing and unboxing.

 

Part G:   Inheritance.

  1. Inheritance in Classes   Employee Example

  2. Inheritance in Arrays   Virtual Example

  3. Abstract Classes   Abstract, Brushes Examples

  4. Exception Handling   TryCatch Example

  5. Interfaces   Intro.Multiclass Example

 

Part H:   Exercise

  1. Create an ASP.Net project that inputs the values Model, Year, and Miles creates a Vehicle object, and stores this object in an ArrayList collection. When a save button is clicked, the application writes the contents of this object to a CSV textfile.

  2. Question: where are you going to keep the collection?

 

Part I:   Two More Interfaces

  1. The IClonable Interface   C#-3.IClonable Example

  2. Implementing a Custom Enumerator   C#-3.CustomEnumerator and C#-3.CustomCollection Examples