无法访问protected成员的问题
小弟我刚学C#,近日在protected上迷糊了.代码如下:using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program:Bank
{
static void Main(string[] args)
{
CheckBank cb = new CheckBank();
cb.AddC();//cb无法访问基类的protected AddC()方法.
Program p = new Program();
p.AddC();//p就可以访问.
}
}
class Bank
{
protected Bank()
{
Console.Write("This is protected constructor.");
Console.ReadLine();
}
protected void AddC()
{
Console.WriteLine("afdas");
}
}
class CheckBank:Bank
{
}
}