This line
public delegate void TrainsAComing();
defines a public delegate type called TrainsAComing , nested inside your class. This would allow users to create delegates such as TrainSignal.TrainsAComing , but TrainSignal would not have a member to store an instance of such a delegate.
In other words, the delegate declaration does not define a member of the delegate type. For this you need another declaration:
class TrainSignal { public delegate void TrainsAComing();
Action , on the other hand, is already a type similar to the delegate TrainsAComing from your example. Therefore, the definition
public Action TrainsAComing;
makes TrainsAComing member of TrainSignal , capable of storing a delegate.
source share