General understanding C #(5 EVENTS) 2

Source: Internet
Author: User

Note:

Public class Game

{

Public event ScoreChangeEventHandler ScoreChange;

Protected void OnScoreChange ()

{

If (ScoreChange! = Null) ScoreChange (30, ref true); // in the class, this can be used

}

Except this class, ScoreChange can only appear on the left of the operator + = and-=]

You may first encounter this system in the graphic user interface framework. A game is like a control on the user interface. It triggers events based on user input, while a referee is similar to a form that processes the event.

[Note] the delegation was first introduced by Microsoft Visual J ++ and was also designed by Anders Hejlsberg. It is also one of the reasons for Sun and Microsoft's technical and legal disputes. James Gosling, a Java designer, once made a humble and humorous comment on Anders Hejlsberg, saying that he should call him "Mr method pointer" because of his disconnections with Delphi ". After studying Sun's dispute over Delegation, I think it seems fair to call Gosling "Everything is a kind of mr." J. In the programming field over the past few years, many people have replaced the "reality is object-oriented, so we should use object-oriented abstraction to simulate it ".

The debate between Sun and Microsoft on delegation can be seen here:

Http://www.Javasoft.com/docs/white/delegates.html Http://msdn.microsoft.com/visualj/technical/articles/delegates/truth.asp]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.