Convert a IList<T> collection to a comma separated list
网上资料 :
// Given: IList<int> collection; string commaSeparatedInts = string.Join(",",collection.Select(i => i.ToString()).ToArray());
我自己的:
1.ShopWebInfo:
[Serializable]
public class ShopWebInfo
{
/// <summary>
/// 商城商品ID
/// </summary>
public int ShopProductID { get; set; }
/// <summary>
/// 商品BaseID
/// </summary>
public int ProductBaseID { get; set; }
/// <summary>
/// 网店ID
/// </summary>
public int CompanyID { get; set; }
/// <summary>
/// 网店名称
/// </summary>
public string CompanyName { get; set; }
/// <summary>
/// 销售价格
/// </summary>
public decimal SalePrice { get; set; }
/// <summary>
/// 赠送积分
/// </summary>
public int Score { get; set; }
/// <summary>
/// 库存剩余
/// </summary>
public int StockNum { get; set; }
}
2.
IList<ShopWebInfo> lstShopWebInfo = new List<ShopWebInfo>();
string[] lstShopID = lstShopWebInfo.Select(i => i.CompanyID.ToString()).ToArray();
string strShopIDList = string.Join(",",lstShopID);
浙公网安备 33010602011771号