Say I have a list of stuffs that will never change.
Is there a way to make it constant?
Something like
Const NEVERTOOHIGH As String() = {"BTC", "BLR", "BIDR", "VAI", "IDRT", "USDT", "USD", "BUSD"}
I can't do this and this will cause compile errors because constant cannot be array
Basically I want the "array" to be accessed everywhere but I want it to be constant. I don't want anyone to change the content of the array or change the array.
Is it possible in vb.net?
In objective-c we can have constant pointer to immutable array. What's in vb.net?
After reading a lot, I can see that the right way to do it would be something like
Public Shared ReadOnly NEVERTOOHIGH As IReadOnlyList(Of String) = {"BTC", "BLR", "BIDR", "VAI", "IDRT", "USDT", "USD", "BUSD", "BRL", "AUD", "ETH", "LTC", "USDC", "UST", "USC", "DAI", "PAX", "EUR", "USDJ", "TUSD"}
Basically I add readonly keywords so NEVERTOOHIGH, even though public, cannot be changed to another list. Also, no one outside my class can change it because I suppose ireadonlylist don't have members like add or remove.
The thing is, I saw so many alternatives. There is IReadOnlyCollection and so on and so on.
I am not even sure I am doing this right though it seems good enough.
So how?