Friday, 1 December 2017

Csharp program Access Specifiers


Code:

using System;
namespace accessspecifier
{
    class Program
    {
        static void Main(string[] args)
        {
            two B = new two();
            B.show();
        }
    }
    class one
    {
        private int x;
        protected int y;
        internal int z;
        public int a;
        protected internal int b;
    }
    class two : one
    {
        public void show()
        {
            Console.WriteLine("Values are : ");
            //x=10;
            y = 20;
            z = 30;
            a = 40;
            b = 50;
            // Console.WriteLine(+x); // Error x is not accessible
            Console.WriteLine(y);
            Console.WriteLine(z);
            Console.WriteLine(a);
            Console.WriteLine(b);
            Console.ReadLine();

        }
    }
}


Output:

Values are :
20
30
40
50



More C# Programs:



















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...