Solved

Cannot implicilty convert type 'IList'

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

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…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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