【发布时间】:2014-10-20 14:30:42
【问题描述】:
我已经用以下类构建了一个类库:
public class Class1
{
public Class1()
{
}
public void Method1()
{
//user should call this method before Method2
}
public void Method2()
{
//user should call Method1 before calling this method
}
}
如何防止用户在调用Method1之前调用Method2? 谢谢
【问题讨论】:
-
不要在公共界面中放置任何用户不应该使用的东西。
-
用户需要同时调用它们
-
那你需要重新设计。