我知道您可以轻松地将数组传递给函数,如下面的代码所示
Private Sub SomeFunction(ByVal PassedArray() As String) For i As Integer = 0 To PassedArray.Count - 1 Debug.WriteLine(PassedArray(i)) Next End Sub Public Sub test() Dim MyArray As String() = {"some","array","members"} SomeFunction(MyArray) End Sub
但有没有办法将常量数组传递给VB.NET中的函数?
例如在PHP中,你可以写:
function SomeFunction($array) { for($i=0;$i<count($array);$i++) { echo($array[$i]); } } function test() { SomeFunction(array("some","members")); // Works for PHP }
重申一下:有没有办法将常量数组直接传递给VB.NET中的函数?这样做有什么好处吗?我想可以节省几个字节的内存.
PS:
SomeFunction({"some","member"}) ' This obvIoUsly gives a Syntax error