Multiple choice .net vb

How do you create a Read only Property in VB.NET

  1. Using Only Get..EndGet with in property definition

  2. Using Only Set..EndSet with in property definition

  3. Using both Get and Set

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

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.

AI explanation

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.