Im getting the warning "Non-nullable event 'SomeEvent' must contain a non-null value when exiting constructor. Consider declaring the event as nullable."
Here's a very simplified version of my code which replicates the exact same problem. What am I missing here? Does this have anything to do with .Net 6?
namespace ConsoleApp3
{
public delegate void SomeDelegate(object sender, EventArgs args);
public class NewClass
{
public NewClass(string name)
{
this.name = name;
}
public string name { get; set; }
public event SomeDelegate SomeEvent;
}
}
public event SomeDelegate SomeEvent = delegate { };
to prevent it from being null – Corradepublic event SomeDelegate? SomeEvent;
should fix that warning, make itnullable
. – TowreySomeEvent?.Invoke(...);
– Ravel