List Info

Thread: Re: Method that returns List




Re: Method that returns List<BaseClass>
user name
2007-12-14 12:53:16
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-DOTNETDISCUSS.DEVELOP.COM] On Behalf Of Curt
Hagenlocher [curtHAGENLOCHER.ORG]
Sent: Friday, December 14, 2007 12:51 PM
To: ADVANCED-DOTNETDISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] Method that returns
List<BaseClass>

On 12/14/07, Ron Young <Ron_Youngcobbsystems.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
curthagenlocher.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


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )