I think if someone puts a Report in your list, which it's type implies is
allowed, your foreach will throw an invalid cast exception.

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Ron Young
Sent: Friday, December 14, 2007 1:46 PM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] Method that returns List<BaseClass>

Indeed it does. Thank you.

I was under the impression that if the method that returned derived reports
ultimately returned a list of the base report, then the client would get the
properties defined in the base report.

But it's up to the client to determine what types of reports are in the
list, so this works:

// client-side
List<Report> reports = provider.GetReports();
foreach (ReportA item in reports)
    WL(item.MyName);

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to