How do you create a Read only Property in VB.NET
-
Using Only Get..EndGet with in property definition
-
Using Only Set..EndSet with in property definition
-
Using both Get and Set
In VB.NET, a read-only property is created by including only the Get accessor without a Set accessor. This allows the property value to be read but not modified from outside the class. Option B (only Set) would create a write-only property, while option C (both Get and Set) creates a read-write property.
In VB.NET, a read-only property is created by defining only a Get accessor (using Get...End Get) inside the property block, with no Set accessor — this means the property's value can be read but never assigned from outside the class, enforcing read-only access. Using only Set...End Set would create a write-only property (can be assigned but never read), the opposite of what's asked. Using both Get and Set creates a fully read-write property, which doesn't satisfy the read-only requirement.