2

I've googled and seen conversions to List<Object>. But I think my case is different. I have the following:

public class Entry
{
    [XmlText]
    public string DataLogEntry { get; set; }
}

and used like this:

public class EndLot
{
    [XmlElement("Entry")]
    public List<Entry> Items;
}

So if I have list of strings ie.

List<string> EndLotLines

How can I create an instance of EndLot with this list. Am trying to:

List<Entry> Items =  (List<Entry>)EndLotLines;       

Read-Only string in settings bundle

I've added a Settings.bundle, however while displaying version numbers I'd like the fields to be read-only.

I've seen a few suggestions that say to change the type from text to title, but when I do this, the settings entry isn't displayed.

enter image description here

4

3 回答 3

8

使用 Linq 的Select方法:

var items = EndLotLines.Select(s => new Entry { DataLogEntry = s }).ToList();
于 2013-04-15T21:22:47.843 回答
2

您必须Entry从每个字符串创建新实例。写这个有意义吗?

Entry e = (Entry)"whatever";

不,您可以使用:

Items = EndLotLines.Select(s => new Entry { DataLogEntry = s }).ToList();
于 2013-04-15T21:23:43.773 回答
1

尝试以下操作:

var endLot = new EndLot
{
   Items = EndLotLines.Select(e => new Entry { DataLogEntry = e }).ToList();
};
于 2013-04-15T21:24:09.070 回答