tags:

views:

305

answers:

1

In C# you can do this to make your member variable immutable:

public readonly int y = 5;

What is the equivalent "readonly" keyword in VB.NET?

+13  A: 

Amazingly enough, it's ReadOnly

Randolpho
Private Const Root_Path as string = "C:\app\data"Private Readonly Backup_Path As String = IO.path.combine(Root_Path, "\Backup")That is one of my favorite uses for it :)
Pondidum
I think what's truly amazing is that it only took me a 30 second google query to determine that.
Randolpho
Hmm, that didnt format so well :(
Pondidum
Suits me right for not trying it. I was stuck thinking ReadOnly only applied to properties. Thanks!
Scott Whitlock
Actually, I kept searching: VB.NET immutable (which was getting me nowhere)
Scott Whitlock
Sometimes, the best tool for helping you search Google is a thesaurus. :)
Randolpho
Well, I really had blinders on. I just "knew" it couldn't be ReadOnly because that was used in the Property declaration, so I was specifically *not* searching for readonly. :) Oh well.
Scott Whitlock