好吧所以我制作了一个列表并将列表拆分了三次,我现在试图将三个列表放入一个结构中,但是在我创建之后无法访问该结构。这是我下面的代码告诉我你的想法
char[] Split1 = { ';' };
List<String[]> Everthing = lists.Select(l => l.Split(Split1)).ToList();
List<String> ID1 = Everthing.Select(dt => dt[0]).ToList();
char[] Split2 = { ',' };
List<String[]> Try = lists.Select(l => l.Split(Split2)).ToList();
List<String> Value1 = Try.Select(dt => dt[1]).ToList();
char[] Split3 = { ':' };
List<String[]> Try2 = lists.Select(l => l.Split(Split3)).ToList();
List<String> Units1 = Try2.Select(dt => dt[1]).ToList();
//How do i get the value, this is the only way i could think of
var FirstTry = new List<Record>();
FirstTry.Add(new Record
{
ID = ID1,
Value = Value1,
Units = Units1
});
}
public class Record
{
public List<string> ID { get; set; }
public List<string> Value { get; set; }
public List<string> Units { get; set; }
}
答案 0 :(得分:0)
如果我正确理解您的问题,您需要访问FirstTry
中结构的字段。例如,要获得ID
中第一个元素的FirstTry
,您可以执行此操作:
FirstTry[0].ID