Professional Documents
Culture Documents
→The Builder design pattern separates the construction of a complex object from its
representation so that the same construction process can create
different representations.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Builder_Pattern
class Program
{
// Create director and builders
director.Construct(b1);
Product p1 = b1.GetResult();
p1.Show();
director.Construct(b2);
Product p2 = b2.GetResult();
p2.Show();
Console.ReadKey();
class Director
builder.BuildPartA();
builder.BuildPartB();
_product.Add("PartA");
_product.Add("PartB");
return _product;
_product.Add("PartX");
_product.Add("PartY");
}
public override Product GetResult()
return _product;
class Product
_parts.Add(part);
Console.WriteLine(part);