Will an empty delegate eat up memory?

后端 未结 2 1800
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-17 18:27
public sealed class FtpManager
{
    public event EventHandler LoggingIn = delegate { };
    private void OnLoggingIn(object sender, EventArgs e)
    {
        var h         


        
2条回答
  •  抹茶落季
    2021-01-17 19:20

    The alternative to doing this is checking LoggingIn for nullity every time you want to raise it. That's liable to be more memory intensive than calling an empty delegate.

提交回复
热议问题