如何从列表对象中获取组合字符串列表?

时间:2013-05-16 21:08:05

标签: c# linq

我有ID和名称的位置列表,如

public class Dim_Location
{
    public int ID{ get; set; }
    public string LocationName{ get; set; }
    public string ClienId{ get; set; }
}  

private List<string> loadLocation(int clientIdx)
{
    List<Dim_Location> LocationList = dim_Location.GetLocation(clientIdx);
      //Combine here List<ID+";"+LocationName> and make List<string>
}

现在我希望从List<ID+";"+LocationName>获取LocationList

1 个答案:

答案 0 :(得分:2)

var result = LocationList.Select(x => x.ID + ";" + x.LocationName);