C# Get Set Modifier

yKneWVss
In this chapter you will learn:

  • What is get set modifier?
  • What is the benefit of using get set modifier?
  • How to use get set modifier in C# programming?

The get set accessor or modifier mostly used for storing and retrieving value from the private field. The get accessor must return a value of property type where set accessor returns void. The set accessor uses an implicit parameter called value. In simple word, the get method used for retrieving value from private field whereas set method used for storing value in private variables.

Example:

Output

Enter your name: Steven Clark

My name is Steven Clark
_

get set method
 

Summary

In this chapter you learned what get set modifier is and how to use it in program. In next chapter, some programming examples are given. It will help you to understand the programming concepts more clearly.



Leave a Reply

Your email address will not be published. Required fields are marked *