我想制作一个具有流畅界面的静态类,但出现错误:
'this' 在静态属性、方法中无效...
这是我的代码:
public static MyClass
{
private static StringBuilder builder;
private static StringBuilder RouteBuilder
{
get
{
if (builder == null)
builder = new StringBuilder();
return builder;
}
}
public static MyClass Root()
{
RouteBuilder.Append("/");
return this;
}
public static MyClass And()
{
RouteBuilder.Append("and");
return this;
}
public static MyClass Something()
{
RouteBuilder.Append("something");
return this;
}
}
这使我能够做到MyClass.Root().And().Something();
有没有办法做到这一点或解决方法?