How to integrate Publisher and subscriber code in a same c# file ?

Hi,
I want to run publisher and subscriber in a same c# file to use it in unity3d does anyone did before?