【问题标题】:c# LINQ joining to comma separated stringc# LINQ 加入逗号分隔的字符串
【发布时间】:2011-08-07 23:56:57
【问题描述】:

我有一串逗号分隔的值,称为 driverids。

  1. 我应该使用逗号分隔列表还是该逗号分隔列表来自的数组在连接中使用它。

  2. 如何在 linq 中使用连接到这些驱动程序 ID?


_currentDriverData.AddRange(elementsCurrent.Join(driverids)

// gets distinct driver ids from the driver duty status change logs;
string driverids = string.Join(",", _logsDutyStatusChange
                         .Select(item => item.did)
                         .Distinct()
                         .ToArray());

//gets all current driver information
//_currentDriverData.AddRange(elementsCurrent.Where(drivers)

_currentDriverData.AddRange(elementsCurrent.Join(driverids).Select.........

【问题讨论】:

  • 你想加入他们什么?
  • 我试图在我的选择中只获取那些驱动程序 ID

标签: c# linq


【解决方案1】:

你会做这样的事情(假设_currentDriverData我们是一个id列表):

_currentDriverData.AddRange(commaSeparatedString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyElements).ToList());

【讨论】:

    猜你喜欢
    • 2015-07-25
    • 2017-09-13
    • 1970-01-01
    • 2013-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多