在下面注释的位置插入你的代码,得到说明中希望的结果!
这是我无意中想到的问题,不知道有没有答案,有兴趣的朋友来试一试吧:-)
using System;
using System.Collections.Generic;
using System.Text;
namespace FindModifier
{
class Finder
{
static void Main(String[] args)
{
PrivateClass privateClass = new PrivateClass();
ProtectedClass protectedClass = new ProtectedClass();
InternalClass internalClass = new InternalClass();
PublicClass publicClass = new PublicClass();
//在这儿插入程序
//希望得到的输出如下,引号中为程序运行结果
//也就是运行中得到类及内部成员的修饰符,不是玩字符串游戏
//PrivateClass's Modifier is "private"
//PrivateMethod of PrivateClass's Modifier is "private"
//ProtectedMethod of PrivateClass's Modifier is "protected"
//InternalMethod of PrivateClass's Modifier is "internal"
//PublicMethod of PrivateClass's Modifier is "public"
//ProtectedClass's Modifier is "protected"
//......
Console.ReadLine();
}
private class PrivateClass
{
private void PrivateMethod()
{ }
protected void ProtectedMethod()
{ }
internal void InternalMethod()
{ }
public void PublicMethod()
{ }
}
protected class ProtectedClass
{
private void PrivateMethod()
{ }
protected void ProtectedMethod()
{ }
internal void InternalMethod()
{ }
public void PublicMethod()
{ }
}
}
internal class InternalClass
{
private void PrivateMethod()
{ }
protected void ProtectedMethod()
{ }
internal void InternalMethod()
{ }
public void PublicMethod()
{ }
}
public class PublicClass
{
private void PrivateMethod()
{ }
protected void ProtectedMethod()
{ }
internal void InternalMethod()
{ }
public void PublicMethod()
{ }
}
}