C#, difference between event and delegate without keyword event, I can't understand

C#.
If you were asked on a technical interview for a job this question, how would you answer it?

Tell me about the difference of these cases:

1)

public class SampleClass
{
    public System.Action a;
}
public class SampleClass
{
    public event System.Action a;
}

>Solution :

Events in C# are a mechanism that classes use to send notifications or messages to other classes. They are a specialized delegate type that we use to notify other classes when something they listen to happens. Events are a vital part of many applications, and a perfect way to decouple and create flexible and extendable applications.

A delegate is a reference to a method. If we call a delegate, the referenced method is called instead. Delegates have all the necessary information to call a method or group of methods with a specific signature and return type. We can pass a delegate as an argument to other methods or we can store it in a structure or a class.

Leave a Reply