Click here to Skip to main content
15,891,375 members
Home / Discussions / C#
   

C#

 
QuestionQuestion For List Generics Pin
Sider8913-Jun-09 22:54
Sider8913-Jun-09 22:54 
AnswerRe: Question For List Generics Pin
0x3c013-Jun-09 23:22
0x3c013-Jun-09 23:22 
GeneralRe: Question For List Generics Pin
Sider8913-Jun-09 23:36
Sider8913-Jun-09 23:36 
GeneralRe: Question For List Generics Pin
0x3c014-Jun-09 0:57
0x3c014-Jun-09 0:57 
GeneralRe: Question For List Generics Pin
Sider8914-Jun-09 1:04
Sider8914-Jun-09 1:04 
GeneralRe: Question For List Generics Pin
0x3c014-Jun-09 1:36
0x3c014-Jun-09 1:36 
GeneralRe: Question For List Generics Pin
Sider8914-Jun-09 5:30
Sider8914-Jun-09 5:30 
GeneralRe: Question For List Generics Pin
0x3c014-Jun-09 5:47
0x3c014-Jun-09 5:47 
This is because you have the wrong return type. The delegate is of type List<Country> LoadChild(int id), but the delegate you try to convert it to is of type List<City> LoadChild(int id). That's the main problem, but it seems more architectural than syntactic. Either your delegate type is wrong, City does not inherit from Country, or City and Country don't implement a common interface. Personally, I wouldn't use a generic delegate at all; I'd go for something like this:
public delegate List<City> LoadCitiesDelegate(int countryId);

public class CountryDAO : BaseDAO<Country>
{
    public override Country Load(int id)
    {
        Country country = base.Load(id);

        if(country != null)
            country.LoadChild = loadCity;
        return country;
    }

    private List<City> LoadCities(int countryId)
    {
        CityDAO cDao = new CityDAO();

        return cDao.LoadList("CountryID=" + countryId.ToString());
    }
}

This probably wouldn't compile, but it's a general idea of the way I would personally do it

Between the idea
And the reality
Between the motion
And the act
Falls the Shadow

GeneralRe: Question For List Generics Pin
Sider8914-Jun-09 19:39
Sider8914-Jun-09 19:39 
QuestionClosing and recreating a form Pin
SimpleData13-Jun-09 22:43
SimpleData13-Jun-09 22:43 
AnswerRe: Closing and recreating a form Pin
Henry Minute14-Jun-09 0:14
Henry Minute14-Jun-09 0:14 
GeneralRe: Closing and recreating a form Pin
SimpleData14-Jun-09 0:15
SimpleData14-Jun-09 0:15 
GeneralRe: Closing and recreating a form Pin
Henry Minute14-Jun-09 0:31
Henry Minute14-Jun-09 0:31 
GeneralRe: Closing and recreating a form Pin
SimpleData14-Jun-09 3:05
SimpleData14-Jun-09 3:05 
GeneralRe: Closing and recreating a form Pin
Henry Minute14-Jun-09 3:13
Henry Minute14-Jun-09 3:13 
GeneralRe: Closing and recreating a form Pin
SimpleData14-Jun-09 3:36
SimpleData14-Jun-09 3:36 
GeneralRe: Closing and recreating a form Pin
Henry Minute14-Jun-09 3:40
Henry Minute14-Jun-09 3:40 
AnswerRe: Closing and recreating a form Pin
Luc Pattyn14-Jun-09 4:14
sitebuilderLuc Pattyn14-Jun-09 4:14 
GeneralRe: Closing and recreating a form Pin
SimpleData14-Jun-09 4:43
SimpleData14-Jun-09 4:43 
GeneralRe: Closing and recreating a form Pin
Luc Pattyn14-Jun-09 4:49
sitebuilderLuc Pattyn14-Jun-09 4:49 
GeneralRe: Closing and recreating a form Pin
SimpleData14-Jun-09 4:52
SimpleData14-Jun-09 4:52 
GeneralRe: Closing and recreating a form Pin
Dave Kreskowiak14-Jun-09 4:58
mveDave Kreskowiak14-Jun-09 4:58 
GeneralRe: Closing and recreating a form Pin
Dave Kreskowiak14-Jun-09 4:55
mveDave Kreskowiak14-Jun-09 4:55 
GeneralRe: Closing and recreating a form Pin
SimpleData14-Jun-09 5:07
SimpleData14-Jun-09 5:07 
GeneralRe: Closing and recreating a form Pin
Dave Kreskowiak14-Jun-09 5:08
mveDave Kreskowiak14-Jun-09 5:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.