簡體   English   中英

c#LINQ加入逗號分隔的字符串

[英]c# LINQ joining to comma separated string

我有一串逗號分隔值,稱為driverids。

  1. 我應該使用逗號分隔列表或此逗號分隔列表來自的數組來在連接中使用它。

  2. 我如何在linq中使用這些驅動程序的連接?


_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.........

你會做這樣的事情(假設_currentDriverData是一個id列表):

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM