有没有简单的方法来使用并行数组? 我有 2 个数组:
public class ApiArray
{
//.. Arrays were filled (E.g. Id:{1,2,7,8,10}, Names:{name1, name2, name3, name4, name5}
public Array Id { get; set; }
public Array Names { get; set; }
}
//..
foreach (var N in ApiArray.Names)
{
listBox1.Items.Add(N);
}
所选的 Names 数组必须链接到 Id 数组中的相同位置。 Id 数组不包含连续数字。
选择名称时,必须使用 ID。
感谢您的建议。
最佳答案
使用Array.Sort(keys,items)
根据数组 keys
中的键对数组 items
进行排序。
关于c# - 并行数组 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11484214/