.net中将 list<> 转换成string类型(1,2,3)
var code = string.Join(",", ProductionLineListCode.Select(item => $"'{item}'"));
string sql = string.Format("select * from mes_Resources where ResCode in({0}) ", code);
list<string> isShow=new List<string>() ///泛型集合
isShow.Add('1')
isShow.Add('2')
isShow.Add('3')
var id_isShow = new StringBuilder(); ///得到的值1,2,3
for (int i = 0; i < isShow.Count; i++)
{
if (i == isShow.Count - 1)
{
id_isShow.Append(isShow[i].ToString());
}
else
{
id_isShow.Append(isShow[i].ToString()+",");
}
}