By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,893 Members | 1,231 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,893 IT Pros & Developers. It's quick & easy.

List conversion

P: n/a
Hello,

I am using the following to convert a CSV String to a List:

updated = paper.Tags.Split(',').Select(p =p.Trim()).ToList();

But I want to place the values in the Name property of a List of Tag
(Tag is a class with 2 properties: ID and Name)

I tried the following:

List<Tagupdated = paper.Tags.Split(',').Select(p =>
p.Trim()).ToList();

But of course I need to place this in each Tag.Name ...

Any idea?

Thanks,
Miguel
Jul 1 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
shapper wrote:
I am using the following to convert a CSV String to a List:

updated = paper.Tags.Split(',').Select(p =p.Trim()).ToList();

But I want to place the values in the Name property of a List of Tag
(Tag is a class with 2 properties: ID and Name)

I tried the following:

List<Tagupdated = paper.Tags.Split(',').Select(p =>
p.Trim()).ToList();

But of course I need to place this in each Tag.Name ...
Try with a new inside Select.

Arne
Jul 2 '08 #2

P: n/a
shapper wrote:
List<Tagupdated = paper.Tags.Split(',').Select(p =>
p.Trim()).ToList();

But of course I need to place this in each Tag.Name ...

Any idea?

Thanks,
Miguel
Hi Miguel,

List<Tagupdated = (from s in paper.tags.Split(',')
select new Tag()
{
Name = s.Trim()
}).ToList();

Regards Tim.

--

Jul 2 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.