I would like to make a static class with a fluent interface but I am getting the error:
'this' is not valid in a static property, method ...
Here is my code:
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;
}
}
This enables me to do MyClass.Root().And().Something();
Is there a way to do this or a workaround?