C# Builder
如下:
class Program { static void Main(string[] args) { var a = new Class1.Builder().BuildA(1).BuildB(2.1).BuildUp(); Console.Read(); } } public class Class1 { private Class1(Builder builder) { A = builder.A; B = builder.B; } internal int A { get; set; } internal double B { get; set; } public class Builder { internal int A { get; set; } internal double B { get; set; } public Builder BuildA(int a) { A = a; return this; } public Builder BuildB(double b) { B = b; return this; } public Class1 BuildUp() { return new Class1(this); } } }