C# Programming - Properties - Discussion

Discussion Forum : Properties - General Questions (Q.No. 14)
Which of the following statements is correct about properties used in C#.NET?
Every property must have a set accessor and a get accessor.
Properties cannot be overloaded.
Properties of a class are actually methods that work like data members.
A property has to be either read only or a write only.
Answer: Option
No answer description is available. Let's discuss.
5 comments Page 1 of 1.

Sridhar said:   6 years ago
Option A correct also Example Public int Eno{get;set;}.

Public string ename {get;set;}.

Every property must declare with get as well as set. Am I right?

Angel said:   9 years ago
But "B" is also correct. Properties cannot be overloaded in C#.

Raghu said:   1 decade ago
Answer D can't be right because it is saying that a property can be either read only or write only.

But it didn't mention that property can be both.

Means read and write only.

Ajay said:   1 decade ago

I think C option is wrong because Properties are used to get (fetch) or set (initialize) the data members in a class it does not work like data members.

Answer D is right we can declare a property either read only or write only. At least one (get or set) should be declare for property.

Vikalp said:   1 decade ago
But sir a property can be read only or write only it is also right.

Post your comments here:

Your comments will be displayed after verification.