-5
我有一個int列表候選鍵和一個int randnumber,它有一些值。對於每個候選鍵,我想添加randnumber。在c中連接int和列表#
怎麼辦?我試過這個:
foreach (int l in candidatekey)
{
candidatekey.Add(randnumber);
}
我有一個int列表候選鍵和一個int randnumber,它有一些值。對於每個候選鍵,我想添加randnumber。在c中連接int和列表#
怎麼辦?我試過這個:
foreach (int l in candidatekey)
{
candidatekey.Add(randnumber);
}
如果我正確理解你,你想給每個候選關鍵碼添加一個隨機數。如果是這種情況,試試這個。
var candidatekey = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
var randomnumber=42;
//we are using LINQ on list
candidatekey=candidatekey.Select(c => c+randomnumber).ToList();
非常感謝這是我想要的 –
發佈你的代碼將使它的方式更便於我們查找問題 –
這只是增加'randomnumber'到列表'candidatekey'。 – TheVillageIdiot