在VB.net中声明一个公共数组 [英] Declaring a public array in VB.net
问题描述
我知道要在VB中声明一个字符串,我会使用该行
I know that to declare a string in VB I would use the line
Dim ExString As String
并声明要使用的全局字符串
And to declare a global string I'd use
Public Shared Property ExString As String
我想使用(假设它已保存在名为GlobalVars的类中)
Which I'd access using (assuming it was saved in a class called GlobalVars)
MsgBox(GlobalVars.ExString)
我也知道声明一个字符串数组是
I also know that to declare a string array it's
Dim ExString(3) As String
但是声明公共数组似乎不起作用同样,该行:
However declaring a public array doesn't seem to work the same, the line:
Public Shared Property ExString(3) As String
似乎不起作用。
我想知道如何在Visual Basic中声明一个公共字符串数组? br>
如果使用Visual Studio 2010,那会有所不同。
Doesn't seem to work.
I was wondering how I go about declaring a public array of strings in visual basic?
I'm using Visual Studio 2010 if that makes a difference.
预先感谢
推荐答案
您不能将长度(3)添加到变量中,因为Visual Studio会na:
You cannot add the length (3) to your variable, because Visual Studio will nag:
期望的标识符。
Identifier expected.
但是您可以执行以下操作:
But you can do something like:
Public Shared Property MyString As String() = New String() { "abc", "def", "ghi"}
这篇关于在VB.net中声明一个公共数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!