Explain get and set in C#.
If we want to change something in private, Why we make it private?
When something is made public, it can be so easily accessed or even modified, no restriction or validation can be implemented. When we create a setter property for a private member, we are allowing a controlled means of modification. That is, we can implement restriction on the new value, define some default when the new value passed doesn't qualify etc. It's part of encapsulation, where an encapsulated member (a private one in this case) can be modified, but the modification is moderated.
The get method returns value of the variable name. The set method assigns a value to the name variable.
Problem Statement Given two integers a and b, your task is to calculate and print the following four values:
Please help, any idea?