集合的并集是合并集合的项,如下图所示:

List<int> ls1 = new List<int>() { 1,2,3,5,7,9 };
List<int> ls2 = new List<int>() { 2,4,6,8,9,10};
IEnumerable<int> unionLs = ls1.Union(ls2);foreach (int item in unionLs)
{
Console.Write("{0}\t", item);
}
集合的交集是取集合的共同的项,如下图所示:

List<int> ls1 = new List<int>() { 1,2,3,5,7,9 };
List<int> ls2 = new List<int>() { 2,4,6,8,9,10};
IEnumerable<int> intersectLs = ls1.Intersect(ls2);foreach (int item in intersectLs)
{
Console.Write("{0}\t",item);
}
本文档主要讲述的是MATLAB与VB混合编程技术研究;着重探讨了在VB应用程序中集成MATLAB实现程序优化的四种方法,即利用Matrix VB、调用DLL动态链接库、应用Active自动化技术和动态数据交换技术,并分析了集成过程中的关键问题及其基本步骤。这种混合编程实现了VB的可视化界面与MATLAB强大的数值分析能力的结合。希望本文档会给有需要的朋友带来帮助;感兴趣的朋友可以过来看看
0
集合的差集是取在该集合中而不在另一集合中的所有的项,如下图所示:

List<int> ls1 = new List<int>() { 1,2,3,5,7,9 };
List<int> ls2 = new List<int>() { 2,4,6,8,9,10};
IEnumerable<int> exceptLs = ls1.Except(ls2);foreach (int item in exceptLs)
{
Console.Write("{0}\t", item);
}
以上就是C#中关于List的并集与交集以及差集解析的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号