如何为列表中的每个项目做一个循环? VB.NET

How to do a loop for each item in a list? VB.NET

我如何为列表中的每个项目做一个循环?

我尝试做一个 For Each 但后来我无法通过它。

我知道它必须以:Next结尾,但我不知道如何为每个项目制作一个循环,这是主要问题。

为了提供更多信息,我正在将列表中的一项写入文本文件,它需要获取列表中的 "n" 项并写入的每一项。

我在做什么:

For Each In listclass.List

    usernameFile.WriteLine(usersClass.UsersName(n))
    usernameFile.Close()

Next```

您看过 VB.net 微软文档了吗?您的第一个 "For Each..." 语句中似乎缺少 "Element" 部分。 Microsoft Docs. Also, try searching for existing answers on Whosebug. Often times, a question has already been answered as in the following: Looping in VB.NET