Solved

Cannot implicilty convert type 'IList'

Posted on 2012-12-26
4
475 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…

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