List<Classname> method()

Hi all im still in the process of learning c#.net and ive come accross this coding

public List<EmployeeDetails> GetEmployees()
{ ....... }

can anyone tell me why <EmployeeDetails> is inside <> and what does it mean having it inside the <>

I dare say its really easy and simple like all things if you already know

thanks

LVL 3
andrew67Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Jon500Connect With a Mentor Commented:
This is the syntax of Generics. What it means is that your List object is going to contains items ONLY of type EmployeeDetails.

Read more here:
http://msdn.microsoft.com/en-us/library/512aeb7t%28VS.80%29.aspx

Enjoy C#!

Cheers,
Jon500
0
 
apexpertCommented:
it is collection of methods of Generics deligate. which make it possible to design classes and methods that defer the specification of one or more types until the class or method is declared and instantiated by client code.
for more information check out these links........
http://weblogs.asp.net/cnagel/archive/2005/03/04/385077.aspx
http://en.csharp-online.net/Understanding_Generics%E2%80%94Creating_Generic_Delegates
http://www.codeguru.com/csharp/sample_chapter/article.php/c11789/

Cheers Dear,
0
 
princeatapiCommented:
List is similar to an Array , by default we will declare array of Type say int , double .. here the list is similar to the collection like array except that this is generic list which can accommodate any defined Datatype or default type or user defined object or built in objects

say
List<int> will hold integer values
List<string>   will store string values
similarly List<EmployeeDetails> will hold object of Type 'EmployeeDetails'
0
 
dampseyConnect With a Mentor Commented:
Because you are learning, let me give a detailed information.

A Variable can hold a value.
such as: int x = 5  or string test = "Hello world"

However, if you want to keep multiple values such as 5,6,7 and 9 you should use array.
Array is again a variable which can hold multiple values. BUT you should know the size if you want to use an array.
int x[] = new int[] {5,6,7,9} //this is the syntax.

if you want to keep multiple values and don't know the size (let's say you get the values from the user), then we use ArrayLists -actually this is old.

ArrayList x = new ArrayList();
x.Add(5);x.Add(6);x.Add(7);x.Add(9);

Array lists keeps each item as Object. Althoug in the example it is an integer.
So there is a convertion between types.
1) Take integer.
2) Convert to Object and Keep.
3) When requested to read convert to integer again and serve.

This is a slow process. No, this is a veri slow process.
So, .net guys desinged
List<> object. This can keep multiple values like an array in its original type and also has an unknown size like an arraylist.

usage: List<int> x = new List<int>();
x.Add(5);x.Add(6);x.Add(7);x.Add(9);

the value adding process is veri similar with arraylists as you can see. However the value is kept in its original type. so there isn't any convertion which means high performans.

You can find more detailed information on the above links.
0
 
andrew67Author Commented:
excellent really really appreciated
0
All Courses

From novice to tech pro — start learning today.