从数组中删除值并重新绑定它

编程入门 行业动态 更新时间:2024-10-28 16:26:59
本文介绍了从数组中删除值并重新绑定它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好,我正在制作一个asp Web应用程序 我有一个数组"bm",该数组中有三个值

hello to all i am making an asp web application I have an array "bm" in this array there are three values

index 0-ram index 1-shyam index 2-sita

现在,在另一个名为"xz"的数组中,我正在检索类似的索引

Now in another array named as "xz" i am retrieving indexes like

Index 0-----value is 0 index 1---- values is 2

现在我想从数组bm中删除索引0和索引1,并再次像这样bm [0] = sita 重新绑定数组bm plz help

now i wants to remove index 0 and index 1 from array bm and rebinds the array bm again like this bm[0]= sita plz help

推荐答案

没有看到您的代码,就不可能完全准确.例如,如果要调用方法来执行此操作,则必须将数组引用作为参考值传递,否则对"bm"进行的任何更改,而不是"bm"数组的内容都不会离开该方法. > 从对"bm [0]"的引用中,我假设您正在使用C#. C#无法从数组中删除元素:您所要做的就是声明另一个数组,然后将所需的元素复制到其中,并忽略不包含的元素.我将使用List而不是数组,因为您无需事先知道将需要多少个元素: Without seeing your code, it is impossible to be totally accurate. For example, if you are calling a method to do this, then the array reference must be passed as a reference value or any change to "bm" rather than the content of the "bm" array will not leave the method. I assume from the reference to "bm[0]" that you are using C#. C# cannot remove elements from an array: all you can do is declare another array and copy the elements you want into it, and omit the ones you don''t. I would use a List rather than an array, as you don''t need to know in advance how many elements you will need: List<string> keepThese = new List<string>(); foreach (string s in bm) { if (IsToBeKept(s)) { keepThese.Add(s); } } bm = keepThese.ToArray();

更多推荐

从数组中删除值并重新绑定它

本文发布于:2023-07-06 20:37:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1054535.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:绑定   组中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!