VB.Net 教程:With… End With 语句

返回到:VB.Net – 循环

With… End With语句不是一个循环结构。 它执行一系列反复引用单个对象或结构的语句。

这个循环结构的语法是:

With object
    [ statements ]
End With

示例:

Module loops
   Public Class Book
      Public Property Name As String
      Public Property Author As String
      Public Property Subject As String
   End Class
   Sub Main()
      Dim aBook As New Book
      With aBook
          .Name = "VB.Net Programming"
          .Author = "Zara Ali"
          .Subject = "Information Technology"
      End With
      With aBook
          Console.WriteLine(.Name)
          Console.WriteLine(.Author)
          Console.WriteLine(.Subject)
      End With
      Console.ReadLine()
   End Sub
End Module

当上述代码被编译和执行时,它产生以下结果:

VB.Net Programming
Zara Ali
Information Technology

返回到:VB.Net – 循环

作者:terry,如若转载,请注明出处:https://www.web176.com/vbnet_api/11455.html

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2023年3月1日
下一篇 2023年3月1日

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注