Determine Calling Object Type in C#

前端 未结 11 865
灰色年华
灰色年华 2021-02-05 14:37

Regardless of whether or not this is a good idea, is it possible to implement an interface where the executing function is aware of the calling object\'s type?

c         


        
11条回答
  •  梦毁少年i
    2021-02-05 14:52

    structure it like a event handler, I'm sure FX cop would even suggest you do this

    static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e)
            {
                throw new NotImplementedException();
            }
    

提交回复
热议问题