> Design Patterns > Flyweight > Flyweight Design Pattern In C#

Flyweight Design Pattern In C#

Flyweight design pattern in C# to support sharing of objects when the objects are in large number with details to granularity of system.


Flyweight design pattern In C#

Output

New Flyweight in pool
Inside ConcreteFlyweight::Operation()
Intrinsic State = 101, Extrinsic State = 10
New Flyweight in pool
Inside ConcreteFlyweight::Operation()
Intrinsic State = 102, Extrinsic State = 20
New Flyweight in pool
Inside ConcreteFlyweight::Operation()
Intrinsic State = 103, Extrinsic State = 30
Flyweight from existing pool
Inside ConcreteFlyweight::Operation()
Intrinsic State = 101, Extrinsic State = 50
Inside UnsharedConcreteFlyweight::Operation()
All State = 500, Extrinsic State = 1000


Suresh Kumar Srivastava is founder of online learning site coursegalaxy.com and author of popular books C In Depth, Data Structures Through C In Depth. He has 18+ years experience in industry and worked on architecture and design of multiple products. This article Flyweight Design Pattern In C# is from his Design Patterns course.