Covariance huh. Thanks for that too, new word to google.
Have read it in a couple blogs but it never sunk in.
________________________________________
From: Discussion of advanced .NET topics.
[ADVANCED-DOTNET DISCUSS.DEVELOP.COM] On Behalf Of Curt
Hagenlocher [curt HAGENLOCHER.ORG]
Sent: Friday, December 14, 2007 12:51 PM
To: ADVANCED-DOTNET DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] Method that returns
List<BaseClass>
On 12/14/07, Ron Young <Ron_Young cobbsystems.com> wrote:
> Is the following possible? The compiler tells me no:
>
> public List<Report> GetReports()
> {
> List<ReportA> reports = new
List<ReportA>();
> reports.Add(new Report());
> return reports;
> }
Covariance is not supported for generics in C#, though I
think the
underlying CLR does actually allow it.
--
Curt Hagenlocher
curt hagenlocher.org
===================================
This list is hosted by DevelopMentorŪ http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
===================================
This list is hosted by DevelopMentorŪ http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|