Solved

Cannot implicilty convert type 'IList'

Posted on 2012-12-26
4
478 Views
Last Modified: 2012-12-26
I get a compile error on this line:
System.Collections.IList instrumentList = new List<Instrument>();

instrumentList = session.CreateCriteria<Financial>("f")
                                       .CreateCriteria("fa.InstrumentList", "il", NHibernate.SqlCommand.JoinType.InnerJoin)
                                        .SetResultTransformer(new NHibernate.Transform.DistinctRootEntityResultTransformer())
                                        .List<Instrument>();

Open in new window

Cannot implicilty convert type 'IList<Instrument>' to Ilist.
What do I need to do?
0
Comment
Question by:allelopath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 22

Expert Comment

by:p_davis
ID: 38721695
why IList just do

List<Instrument> instrumentList = new List<Instrument>();
0
 
LVL 1

Author Comment

by:allelopath
ID: 38721716
That gives another compile error:
The non-generic Ilist cannot be used with type arguments
0
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 200 total points
ID: 38721882
IList has no relationship with IList<>, therefore you cannot convert between them. The unique common interface is IEnumerable
On the other hand, List<> implements IList, so if you can cast a collection to List<> instead of IList<>, then you can assign it to a non-generic IList.
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 300 total points
ID: 38721886
Change line 1 to (edited):

System.Collections.Generic.IList<Instrument> instrumentList = new List<Instrument>();

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question