编程语言
首页 > 编程语言> > C# for循环创建数组

C# for循环创建数组

作者:互联网

#region 获取数组
//将dt stockid字段数据传进list
List<int> liststock = new List<int>();
for (int i = 0; i < dtStock.Rows.Count; i++)
{
    liststock.Add(int.Parse(dtStock.Rows[i]["FSTOCKID"].ToString()));
}
List<int> listNew = new List<int>();
//删除重复数据
foreach (int eachString in liststock)
{
    if (!listNew.Contains(eachString))
        listNew.Add(eachString);
}
//赋值给数组
int[] stockID = listNew.ToArray();
#endregion

标签:listNew,C#,创建,List,int,数组,liststock,eachString
来源: https://blog.csdn.net/weixin_44679229/article/details/120558055