I once attended a Microsoft Technet Event where they were showing off the new (at the time) .Net 3.0 features. As a self-taught .Net developer, I’m always looking for little tricks and shortcuts and cool things that make my life easier. As I watched the Demo, one thing I noticed was they were using a method that allowed for the use of an infinate number of parameters of the same type. I went home after the conference and immediately began researching what this infinate parameter was and how to use it in my own methods.
Read more »
January 28, 2008
Posted by
Broken Bokken |
.Net |
.Net, .Net 2.0, .Net Dojo, ASP.NET, C#, Development, Generics, List, Parameter, Parameter Lists, Params, Programming, Technology |
2 Comments
In 2.0, Generics were added. If you haven’t played with generics before, they are a way of declaring a type for an object for the compiler, such as a list, without having to use the System.Object class. In this way, you can have strongly typed lists instead of a list of objects that you must then typecast when you pull them back out.
If you think of generics outside the programming world, you might think of generic medicine. It is medicine that has the same effects as the name brand stuff, but isn’t attached to any brand. Generics in programming are like this. They aren’t bound to a type, but share the same methods and classes.
Here are a few examples of the List object from System.Collections.Generics. The list is exactly as it says. You add items to the list that are the same type as you delcare, and then access them using a zero-based index. It’s similar to the ArrayList from System.Collections, but the return type of the items is not System.Object that must be typecast.
Read more »
November 27, 2007
Posted by
Broken Bokken |
.Net |
.Net, .Net 2.0, .Net Dojo, ASP.NET, C#, ChangeType, Convert, Generic Return, Generics, IConvertible, Programming, Return Type, System.Collections.Generic, Technology, TypeCast, typeof |
1 Comment