VB -Parentheses! Please explain?

后端 未结 2 1560
余生分开走
余生分开走 2021-01-21 05:04
Sub Main() 

    Console.WriteLine(\"check\")   
    Console.Read()

End Sub

Why does Sub Main () need them? How do they apply to this procedure? .Wri

2条回答
  •  既然无缘
    2021-01-21 05:45

    When calling a method you do have a choice in VB whether you want to include the parentheses if there are no parameters. The same holds true for the definition of a method, be it a function or a sub.

    See http://msdn.microsoft.com/en-us/library/dz1z94ha.aspx (Sub Statement on MSDN).

    Calling a Sub Procedure

    You call a Sub procedure by using the procedure name in a statement and then following that name with its argument list in parentheses. You can omit the parentheses only if you don't supply any arguments. However, your code is more readable if you always include the parentheses.

提交回复
热议问题