Property Accessibility
C# provides a standard set of accessibility modifiers for use on class members.
public string Category { get; set; }
protected string Category { get; set; }
internal string Category { get; set; }
protected internal string Category { get; set; }
private string Category { get; set; }
public string Category { get; set; }
- Use public to grant access to the property from any code. this is very common, especially for properties that are defined in a business layer component, and are displayed and edited in a user component.
protected string Category { get; set; }
- Protected most use often when working with inheritance and base class.
internal string Category { get; set; }
- Internal limits access to only the component in which the property is defined.
protected internal string Category { get; set; }
- Protected internal limits access to the same component and to inheritance classes.
private string Category { get; set; }
- Private limits access to only the class in which the property is declared.
Comments
Post a Comment