Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Linq to List of string not working

Posted on 2012-03-22
3
Medium Priority
?
360 Views
Last Modified: 2012-03-22
hello ee,

i have this:    dim q = (From x in myTable Select x.Field(Of String)("CompanyNo")).Distinct()

wich reuslt as:

"01"
"02"
"00"

I have :   Dim list as new List(Of String)

Im trying:       list = q  
to fill my List with "01" "02" "00"

but i have error

how can I fill my list with q ?
0
Comment
Question by:PhilippeRenaud
[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
3 Comments
 
LVL 38

Accepted Solution

by:
PaulHews earned 1600 total points
ID: 37753310
Have you tried:

list = q.ToList()
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 400 total points
ID: 37753365
Right (with respect to PaulHews). The "thing" returned by your query is defined by function you last called against the query (I'm speaking of Distinct in this case), or the query itself if you don't execute any function against it. The Distinct method returns back an IEnumerable(Of T), which is not a List(Of T). A IEnumerable(Of T) can be loaded or turned into a List(Of T), but it is not the same as a List(Of T). You can use the aforementioned ToList extension method to convert the IEnumerable(Of T) you get back from Distinct into a List(Of T).

* I'm using the generic terms "Of T". You are using String, so substitute String for T in the above description.
0
 
LVL 1

Author Closing Comment

by:PhilippeRenaud
ID: 37753376
thanks, actually I tried but went to fast and my toList() was placed at the wrong place.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

705 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