List<Classname> method()

Hi all im still in the process of learning 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


Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

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:

Enjoy C#!

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........

Cheers Dear,
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

List<int> will hold integer values
List<string>   will store string values
similarly List<EmployeeDetails> will hold object of Type 'EmployeeDetails'
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();

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>();

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.
andrew67Author Commented:
excellent really really appreciated
All Courses

From novice to tech pro — start learning today.