在 VB.NET 中连接数组
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/220387/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Join arrays in VB.NET
提问by jimtut
What's the simplest way to join one or more arrays (or ArrayLists) in Visual Basic?
在 Visual Basic 中连接一个或多个数组(或 ArrayLists)的最简单方法是什么?
I'm using .NET 3.5, if that matters much.
我正在使用 .NET 3.5,如果这很重要的话。
采纳答案by mwilliams
You can take a look at this thread that's titled Merging two arrays in .NET.
您可以查看标题为在 .NET 中合并两个数组的线程。
回答by TheSoftwareJedi
This is in C#, but surely you can figure it out...
这是在 C# 中,但您肯定可以弄清楚...
int[] a = new int[] { 1, 2, 3, 4, 5 };
int[] b = new int[] { 6, 7, 8, 9, 10 };
int[] c = a.Union(b).ToArray();
It will be more efficient if instead of calling "ToArray" after the union, if you use the IEnumerable given instead.
如果您使用给定的 IEnumerable 而不是在联合之后调用“ToArray”,则效率会更高。
int[] a = new int[] { 1, 2, 3, 4, 5 };
int[] b = new int[] { 6, 7, 8, 9, 10 };
IEnumerable<int> c = a.Union(b);