IT. Expert System.

C#

protected


The protected keyword is a member access modifier. A protected member is accessible within its class and by derived class instances. For a comparison of protected with the other access modifiers, The statement a.x = 10 generates an error because it is made within the static method Main, and not an instance of class B. Struct members cannot be protected because the struct cannot be inherited. In this example, the class DerivedPoint is derived from Point. Therefore, you can access the protected members of the base class directly from the derived class.

Syntax:
protected variable;

protected Function()
{
//body
}


Example:

class Point 
    {
        protected int x; 
        protected int y;
    }

    class DerivedPoint: Point 
    {
        static void Main() 
        {
            DerivedPoint dpoint = new DerivedPoint();

            // Direct access to protected members:
            dpoint.x = 10;
            dpoint.y = 15;
            Console.WriteLine("x = {0}, y = {1}", dpoint.x, dpoint.y); 
        }
    }
    // Output: x = 10, y = 15


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 228 / 158765898. Delta: 0.01849 с