删除字符串数组元素 [英] Deleting string array elements

查看:68
本文介绍了删除字符串数组元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个字符串数组,我试图在一个数组中查找元素,该数组至少包含第二个元素.如果找不到匹配项,那么我希望从第一个数组中删除相应的元素.我该怎么办?

I have two string arrays and I am trying to find element in one array which contains at least one element from the second. If no match is found then I want the corresponding element from the first array removed. How can I do this?

谢谢

致谢

           For Each x In JoinsArray
                Dim Found As Boolean = False
                For Each y In TablesArray
                    If x.Contains(y) Then
                        Found = True
                    End If
                Next
                If Not Found Then
                    ' Delete element corresponding to x here
                End If
            Next

推荐答案

我有两个字符串数组,我试图在一个数组中查找元素,该数组至少包含第二个元素.

I have two string arrays and I am trying to find element in one array which contains at least one element from the second.

那是一个十字路口.如果使用列表而不是数组,则有一个用于交集的扩展方法:
https://msdn.microsoft.com/en-us/library/bb355408 (v = vs.110).aspx

That's an intersection.  If you use lists instead of arrays then there is an extension method for intersection:
https://msdn.microsoft.com/en-us/library/bb355408(v=vs.110).aspx

您尚未说明对象是什么,但是上面的示例包含用于创建对象比较器的模板.

You have not indicated what your objects are, but the example above includes a template for creating the object comparer.


这篇关于删除字符串数组元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆