Generics

Posted by Nagarjun.singarapu under ASP.NET on 9/21/2009 | Views : 6081 | Status : [Member] | Replies : 2
hi friends,

What is meant by Generics ?




Responses

Posted by: Initiotech on: 9/21/2009 [Member] Starter

Up
0
Down
DotNet 2.0 introduces as Type safe datatype which is known as Generics.

Generics are mostly Type-Safe Collections.
Like the List<type> ,SortedList<type> Etc...

Example of a Custom Built Generic Class :-
class Employee<T>

{
public T Id;
}

Using the Generic Class Employee
class Test

{
public static void Main()
{
Employee<string> emp1=new Employee<string>();
emp1.Id="Hefin";

Employee<int> emp2=new Employee<int>();
emp1.Id=1;

}
}


Nagarjun.singarapu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Neeks on: 9/22/2009 [Member] Bronze

Up
0
Down
You will get enough reference for the Generic by using the site given below


http://www.15seconds.com/issue/031024.htm

Nagarjun.singarapu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response