如何删除我的 ArrayList 中的实际项目 [英] How to remove the actual item in my ArrayList

查看:30
本文介绍了如何删除我的 ArrayList 中的实际项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用一个 ArrayList 并且我必须删除实际的项目,但我不知道该怎么做,你能帮我吗?这是我的代码:

I have to work with an ArrayList and I have to remove the actual item and I don't know how to do, can you help me please? here's my code :

Public Sub Effacer_etu()
    Try
        _listeEtu.RemoveAt(NB_Etu - 1)
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub

附言NB_Etu 是我的 ArrayList 中的学生人数

P.S. NB_Etu is the number of students in my ArrayList

推荐答案

Joël,

您的代码不必要地使用了循环.您只需要一行代码即可删除该项目.试试这个:

Your code uses a loop unnecessarily. You just need one line of code to remove the item. Try this:

Public Sub Effacer_etu()
    Try
        _listeEtu.Remove(_etudiant)
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub

您将获得相同的结果,而无需进行不必要的循环.

You will get the same result without the unnecessary looping.

这篇关于如何删除我的 ArrayList 中的实际项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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