Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

(6, 7) c sharp introduction_advanced_features_part_i_part_ii_exercises

These exercises belong to: http://de.slideshare.net/nicolayludwig/6-c-sharp-introductionadvancedfeaturesparti and http://de.slideshare.net/nicolayludwig/7-c-sharp-introductionadvanvcedfeaturespartii

- Namespaces
- Assemblies
- Error Handling with Exceptions
- Enums
- Value Types and Reference Types
- Object-based and generic Collections
- Delegates and Events
- Custom Attributes
- Reflection

  • Als Erste(r) kommentieren

  • Gehören Sie zu den Ersten, denen das gefällt!

(6, 7) c sharp introduction_advanced_features_part_i_part_ii_exercises

  1. 1. Exercises: 1. The type Era from the former Car exercise should be expressed as enum. 2. The different constraints (often also called "invariants") found in the former Shape exercise (sides and radii greater than 0, positions' coordinates greater than 0, maybe also a == b for squares) should be expressed with exceptions. If any of these invariants is hurt, an exception will be thrown with an appropriate message. The functionality of the constraint violation and raised exceptions should be checked in a unit test. a) Will you write new exception types or will you use the present .Net exception types to solve the described exercise? - Explain your decision! 3. Re-implement the type DynamicArray from a former exercise to make it a generic type. 4. A program should read a text file and store each read line into a generic .Net Collection type (No array!). a) Which .Net Collection did you select? - Why? b) The program should then sort the lines lexicographically and write a new text file with the sorted lines. c) Think about how to implement unit tests! d) Write a little user guide how the program should be used. 5. This exercise is based on exercise 4). Add the DevNetZip library into your project (http://dotnetzip.codeplex.com/). Use its features to compress the resulting text file of the exercise 4. b) into a zip archive. 6. A program should read a text file and store each read line into a string[]. Following tasks should be implemented with the static methods of the .Net types System.Array and delegates. Hint: Try to write code, which does not use any loops. a) Print all lines to the console, which do not start with a vowel. b) Print all lines to the console, which have an even count of characters. c) The user should be asked for a text and the program should output all lines containing this text. d) Write some unit tests. e) Write a little user guide how the program should be used. 7. Inspect the event System.AppDomain.ProcessExit! a) What is an application domain? - Document your findings! b) When is this event raised? - Document your findings! c) Implement a handler for that event and prove that the event was raised. 8. The event TankEmpty should be implemented for the type Car of one of the former exercises. a) Show the usage and functionality of this event in a unit test. 9. Extract as many information as possible from the type string by the usage of .Net reflection. Store the gained "profile" of that type into a text file in a format you find appropriate. 10.Read the chapters eight to twelve of the book "Visual C# 2010"! Remarks: • The usage of the keywords var, dynamic, foreach and goto is not allowed! • Avoid magic numbers and use constants where possible. • The results of the programming exercises need to be runnable applications! All programs have to be implemented as console programs. • The programs need to be robust, i.e. they should cope with erroneous input from the
  2. 2. user. • You should be able to describe your programs after implementation. Comments are mandatory. • In documentations as well as in comments, strings or user interfaces make correct use of language (spelling and grammar)! • Put your solutions into the TFS repository. • Don't panic: In programming multiple solutions are possible. • If you have problems use the Visual Studio help (F1), books and the internet primarily. • Of course you can also ask colleagues; but it is of course always better, if you find a solution yourself.