List<Classname> method()

Posted on 2010-01-05
Last Modified: 2013-12-17
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


Question by:andrew67
    LVL 8

    Accepted Solution

    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#!

    LVL 4

    Expert Comment

    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,
    LVL 11

    Expert Comment

    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'
    LVL 8

    Assisted Solution

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

    Author Closing Comment

    excellent really really appreciated

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now