标签:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Person p1 = new Person();
p1.Name = "小明";
p1.height = 180;
p1.Age=20;
p1.Say();
}
}
public class Person
{
string Name;
public int height;
public int Age;
public void Say()
{
Console.WriteLine("你好,我叫{0},身高{1},年龄{2}",this.Name,this.height,this.Age);
}
}
}
这是因为在 string Name的前面没有加上public 导致访问级别低!
关于:“ConsoleApplication1.Person.Name”不可访问,因为它受保护级别限制
标签:
原文地址:http://www.cnblogs.com/jzqblogs/p/4221301.html