You need to sign in to do that
Don't have an account?

private set usage in apex controller
Hi,
What is the difference between set and private set? And when do we use private set?
example:
public ApexPages.StandardSetController ssc {get; private set;}
Please advice.
-Kaity
What is the difference between set and private set? And when do we use private set?
example:
public ApexPages.StandardSetController ssc {get; private set;}
Please advice.
-Kaity
You can refer to this document:
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_properties.htm
In your code as mentioned above, it's public to read value but it's private to write value.
Thanks,
Pratik
P.S. If this answers you question, please mark it as "Best Answer" so it will help other community members too.
-Kaity
Get and Set are properties to read and write the values respectively. To set their accessibility within or outside of the class, we use private, public, protected access mofifiers.
Please go through the example.
Example:
global virtual class PropertyVisibility {
// X is private for read and public for write
public integer X { private get; set; }
// Y can be globally read but only written within a class
global integer Y { get; public set; }
// Z can be read within the class but only subclasses can set it
public integer Z { get; protected set; }
}
Thanks,
Pratik