Is there a way to create a constant shared array? The ovbious way :

Shared Const GX() As String = {"GS", "GP"}

Is not working, it says you can't use shared and const together.

If you use only const it says you can't declare a contant array in a class.

Thanks in advance

有帮助吗?

解决方案

I don't think it's possible. An alternative would be to use ReadOnly

Public Shared ReadOnly GX() As String = {"GS", "GP"}

其他提示

Sadly, you are not able to use Arrays in constants...

See here for details...

You cannot use the Shared modifier in a Const Statement (Visual Basic), but constants are implicitly shared. Similarly, you cannot declare a member of a module or an interface to be Shared, but they are implicitly shared. Read this MSDN Document. You can not use shared and constant in same time

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top