Click here to Skip to main content
15,895,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
using System.Collections;
using System.Collections.Generic;

/// <summary>
/// Summary description for BookManager
/// </summary>

public class BookManager
{
    public List GetBooks ()
    {
        List list = new List();

        list.Add(new Book(101, "Java", 34.99));
        list.Add(new Book(102, "HTML", 31.99));
        list.Add(new Book(103, "XSLT", 37.99));
        list.Add(new Book(104, "XML", 59.99));
        list.Add(new Book(105, "XHTML", 35.99));
        list.Add(new Book(106, "CSS", 35.99));

        return list;
    }
}



--Error 1 Using the generic type 'System.Collections.Generic.List<t>' requires '1' type arguments
Posted
Updated 8-Aug-13 12:24pm
v2

Use the fllowing line instead:
C#
List<Book> list = new List<Book>();
 
Share this answer
 
Comments
anurag19289 8-Aug-13 4:48am    
Thanks.. its working now :)
You've included the Generic namespace.

Change;
C#
public List GetBooks ()
{
    List list = new List();

    list.Add(new Book(101, "Java", 34.99));
    list.Add(new Book(102, "HTML", 31.99));
    list.Add(new Book(103, "XSLT", 37.99));
    list.Add(new Book(104, "XML", 59.99));
    list.Add(new Book(105, "XHTML", 35.99));
    list.Add(new Book(106, "CSS", 35.99));

    return list;
}


To
C#
public List<Book> GetBooks ()
{
    List<Book> list = new List<Book>();

    list.Add(new Book(101, "Java", 34.99));
    list.Add(new Book(102, "HTML", 31.99));
    list.Add(new Book(103, "XSLT", 37.99));
    list.Add(new Book(104, "XML", 59.99));
    list.Add(new Book(105, "XHTML", 35.99));
    list.Add(new Book(106, "CSS", 35.99));

    return list;
}



Hope this helps,
Fredrik
 
Share this answer
 
Comments
anurag19289 8-Aug-13 4:48am    
Superb,,,,:) thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900