【发布时间】:2015-07-27 16:56:47
【问题描述】:
我有一个名为 Point 的部分类,我想在其中创建一个 JustTest 方法来练习(这没有意义,因为它只是写出一行),但是我收到此错误“`Program.Point .JustTest()' 由于其保护级别而无法访问”。
public partial class Point
{
private int x;
private int y;
public Point (int x, int y)
{
this.x = x;
this.y = y;
}
partial void JustTest();
}
public partial class Point
{
partial void JustTest()
{
Console.WriteLine("Should I work?");
}
public int setX
{
set
{
x = value;
}
get
{
return x;
}
}
public int setY
{
set
{
y = value;
}
get
{
return y;
}
}
}
static void Main()
{
Point p1 = new Point(20,30);
p1.JustTest();
}
【问题讨论】:
-
JustTest() 是
private。部分部分与这个错误无关,虽然你用错了。
标签: c#