gpt4 book ai didi

vb.net - 如何在 Visual Basic 中使用 while 循环读取 StreamReader?

转载 作者:行者123 更新时间:2023-12-05 08:44:47 26 4
gpt4 key购买 nike

考虑:

Dim line As String
Using readFile As New StreamReader(SalesUpdateFile)

While (line = readFile.ReadLine) IsNot Nothing

我是 Visual Basic 新手。每次我运行这段代码时,它都会给我这个错误:

"IS" requires an operand that have a reference type

我该如何解决这个问题?

最佳答案

虽然 Konamiman 的回答非常好,但我不喜欢 repeat myself因此,更喜欢以下模式以避免重复调用 ReadLine():

Do
Dim line = reader.ReadLine()
If line Is Nothing Then Exit Do
' Process the line
Loop

关于vb.net - 如何在 Visual Basic 中使用 while 循环读取 StreamReader?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1714234/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com