5/26/2005

Generics!

Filed under: General — russell @ 2:54 pm

Datatype mis-matches being caught at compile time versus runtime (Oh what I wouldnt give). With the amount of data work that I code, it is always an issue to deal with data that does not match its storage format. For example I have a structure that expects an integer and the user (or database) gives it a string. Either you code to protect it (can you say validate validate validate), or your code blows up at runtime. Enter "generics."

Using Generics, you do not need to fix the data type of the items used by your objects/code. Instead, you use the new keyword: "Of" which identifies the data type parameter on a class, structure, interface, delegate, or procedure. For example:

Code:
Public Class MyStack(Of itemType)
Code:
Dim stackA As New MyStack(Of Integer)

This is taken from a recent Oreilly article which can be found here: CLICK

COMING SOON TO .NET NEAR YOU (.Net 2.0)


No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment

Couldn't find your convert utility. Check that you have ImageMagick installed.