Solved

Linq to List of string not working

Posted on 2012-03-22
3
350 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 400 total points
ID: 37753310
Have you tried:

list = q.ToList()
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 100 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

759 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