Why we use get and set method in c#?



Why we use get and set method in c#?..

Answer / Suraj Vikram Shahi

Get and Set methods are used in C# to control the access to the private fields of a class. The Getter (get) method retrieves the value of the field, while the Setter (set) method sets the value of the field, ensuring data integrity and providing encapsulation.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

Why ienumerable is used in c#?

1 Answers  


What do you mean by generic class in c#?

1 Answers  


Describe an abstract class?

1 Answers   Siebel,


What is sql transaction in c#?

1 Answers  


What is the namespace for datatable in c#?

1 Answers  


What does firstordefault mean in c#?

1 Answers  


What is expression c#?

1 Answers  


coding for delegates?

3 Answers   Tech Mahindra,


Is a structure a class?

1 Answers  


Can I use ReaderWriterLock instead of Monitor.Enter/Exit for Threading?

1 Answers   HCL,


What does it meant to say “the canonical” form of XML ?

1 Answers  


How to update the gui from another thread in c#?

1 Answers  


Categories