sloan
Sun Oct 07 19:14:49 PDT 2007
public class Employee{}
public class EmployeeCollection : List<Employee>
{
}
instantiate an instance of EmployeeCollection, and see all the wonderful
methods, that are STRONGLY TYPED.
ex:
EmployeeCollection ec = new EmployeeCollection();
Employee e = new Employee();
ec.Add ( e ) ; //<< Notice the add takes an Employee as a param, not an
"object".
That's def not the only thinng you can do. but its a start. The benefit is
that anytime you need a collection, all you do is this:
List < MyCustomObject > = new List <MyCustomObject >();
//or use my method above of EmployeeCollection.
Because you get strong typing, your code is alot less buggy.
Check this blog entry out:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!151.entry
It gives you access to the Session object, but in a strongly typed way ...
But you can also see how to use generics in a slightly different way that
just collection based ones.
"Bhuwan Bhaskar" <kxxx@gmail.com> wrote in message
news:OtGaxKMCIHA.3884@TK2MSFTNGP05.phx.gbl...
> Hi,
>
> What are generics? How generics can be used in our application?
>
> Thanks & Regards
> Bhuwan
>