How to write reusable codes?

 

I have a requirement to use stack in my indicator.  Stack, as most of us know,  is FIFO ADT with Push and Pop operation.

Question is: How do I write a stack that can handle generic types?  i.e., it should be able to Push and Pop string, integer, struct or even objects whenever I have a need for it.