删除另一个数组中的一个数组 [英] Delete an array inside another array

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

问题描述

我有一个包含另一个数组的数组.我想删除第二个数组中的索引和元素.如何实现

解决方案

您只需要从外部数组中删除包含内部数组的项目.
要删除常规数组的元素,请参见 Stack Overflow上的此问题 [ ^ ].

除非第一个数组是数组数组",否则它不能包含另一个数组"-它可以包含对相同元素的引用,但不能包含相同数组本身.

如果是数组数组,则可以删除数组引用,但是不能在不重新创建数组的情况下删除元素,就像在不创建任何数组的情况下不能从任何其他数组中删除元素一样包含所有其他元素的新数组.

我建议您考虑使用List< T>代替数组.相反,您可以从其中删除元素而不会出现任何问题.


I have an array that contains another array.i want to delete the index and elements in the second array.how can this be achieved

解决方案

You just need to remove from the outer array the item containing the inner one.
For removing an element of a regular array see this question at Stack Overflow[^].


Unless the first array is an "array of arrays", then it cannot "contain another array" - it can contain references to the same elements, but it can''t contain the same array itself.

In the case of an array of arrays, you can remove the array reference, but you can''t delete the element without recreating the array anew, just the same as you can''t remove an element from any other array without creating a new array that just contains all the other elements.

I would suggest that instead of an array, you consider a List<T> instead - you can delete elements from that without any problems.


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

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