mtelligent

View Original

Exam 70-553 - Manage data in a .NET Framework application by using .NET Framework 2.0 system types.

Here is the first of my notes on Exam 70-553:

Section 1

  • Part 1
    • Topic 1

Developing applications that use system types and collections Manage data in a .NET Framework application by using .NET Framework 2.0 system types. (Refer System namespace)

  • Value types
  • Reference types
  • Attributes
  • Generic types
  • Exception classes
  • Boxing and UnBoxing
  • TypeForwardedToAttributes

Summary

This Section is pretty basic except for a couple of new concepts.

Value Types are stored and passed by value and include all the primitive data types such as int and bool. Structs and Enums are also value types. Reference types are objects, they can be set to null are passed as references. Attributes are used to declare meta information about a class, method or parameter. You can create your own Attribute types and Reflection can be used to look at what attributes are decorating different members. Generic Types are types that need a base type declared when creating an instance of the type.

Generics are new to .Net 2.0 and are similar in concept to C templates. The basic concept is to design a class without declaring a specific type. Then when you declare the type in your program you specify what type or types the generic types actually are. Look at the resources if you are unfamiliar.

Exception Classes are used to halt process flow and alert any calling functions as to a problem.

Boxing and unboxing refers to storing a strong type in an object container (boxing it) and then taking it out and casting it back to the strong type (unboxing it).

TypeForwardToAttributes was not an easy topic to research. The best explanation I found at the time of this writing was a blog comment which is referenced in the other resources and links. In case it contents change, the following is an excerpt from the post:

With type forwarding you can avoid consumers of your assembly having to recompile.

It works like this

1. Code a new assembly (A2).
2. Move type T1 to from A1 to A2.
3. Remove T1 from A1.
4. Reference A2 from A1
5. Add a TypeForwardedTo attribute to A1, pointing at T1 (now in A2)
6. Recompile A1 and A2.
7. Replace the original A1 with the new A1 and A2 (in the locations used by APP)

Now when the CLR loads APP, it will look in A1 for T1 but find the type forward instead, causing it to look in A2 instead. Thus T1 has been moved to a new assembly while not breaking binary compatibility with APP .

Other Resources & Links:

Value Types in the Common Type System
http://msdn2.microsoft.com/en-us/library/34yytbws(en-US,VS.80).aspx

Attributes and Declarative Programming
http://www.knowdotnet.com/articles/attributes.html

Introducing .NET Generics
http://www.15seconds.com/issue/031024.htm

.NET exceptions for the exceptionally challenged
http://builder.com.com/5100-6373-1044971.html

Boxing and Unboxing
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=38

Forwarding Types
http://notgartner.com/posts/2955.aspx