I find I have more success using a delegate/event set up, rather than using an Action, but I had a question about my coding, and Invoking said event…
For example, for the shop changing event, this is how I have set up my initial event…
public delegate void ActiveShopChanged();
public event ActiveShopChanged shopChanged;
public void SetActiveShop(Shop shop)
{
activeShop = shop;
if(shopChanged != null)
{
shopChanged?.Invoke();
}
}
my question is, do I need the null check, since I am using the “?” in my invoke… is that a redundant check? would the check for null be the same is I just wrote
public delegate void ActiveShopChanged();
public event ActiveShopChanged shopChanged;
public void SetActiveShop(Shop shop)
{
activeShop = shop;
shopChanged?.Invoke();
}
This is not exactly related to the course, but I just want to make sure I am getting a grasp on the language. Thanks.