C# Program using protected keyword


In this program, You will learn how to implement the protected keyword in C#.


public class A { 
    protected int x = 10; 
}

Example: How to implement the protected keyword in C#.

using System;
public class A
{
	protected int x = 10;
}

public class B : A
{
	public void display()
	{
		Console.WriteLine("x value is:" + x);
	}

	public static void Main(string[] args)
	{
		B t1 = new B();
		t1.display();
	}
}

Output:

x value is:10