Constant Shared array in vb.net
17,260
Solution 1
I don't think it's possible. An alternative would be to use ReadOnly
Public Shared ReadOnly GX() As String = {"GS", "GP"}
Solution 2
Sadly, you are not able to use Arrays in constants...
See here for details...
Solution 3
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
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on June 17, 2022Comments
-
Admin about 2 years
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