Domanda

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

È stato utile?

Soluzione

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

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

Altri suggerimenti

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top