在VB.net中声明一个公共数组 [英] Declaring a public array in VB.net

查看:121
本文介绍了在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆