Pregunta

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

¿Fue útil?

Solución

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

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

Otros consejos

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top