What is the syntax for making a property read-only?

  1. Property Read propertyname As datatype

  2. Read Property propertyname As datatype

  3. ReadOnly Property propertyname As datatype

  4. Read-Only Property propertyname As datatype

  5. RO Property propertyname As datatype


Correct Option: C

AI Explanation

To make a property read-only, the correct syntax is:

C. ReadOnly Property propertyname As datatype

In Visual Basic, the "ReadOnly" keyword is used to define a property that can only be read but not written to. This means that the property can be accessed for reading its value, but it cannot be assigned a new value.

The syntax for creating a read-only property in Visual Basic is:

ReadOnly Property propertyname As datatype

By using the "ReadOnly" keyword, you indicate that the property is read-only, and the "Property" keyword is used to define a property. "propertyname" is the name of the property, and "datatype" represents the data type of the property's value.

Therefore, option C is the correct syntax for making a property read-only.

Find more quizzes: