正确命名C#事件和处理程序[已关闭]

从我所看到的,我不知道我是否拥有正确的事件和处理程序的命名约定。 (在那里似乎有一些矛盾的建议)。

在下面的两个类中,任何人都可以告诉我,如果我有事件的命名权,引发事件的方法和处理事件的方法?

public class Car
{
 // is event named correctly?
 public event EventHandler<EventArgs> OnSomethingHasHappened;

 private void MoveForward()
 {
  RaiseSomethingHasHappened();
 }

 // is the named correctly
 private void RaiseSomethingHasHappened()
 {
  if(OnSomethingHasHappened != null)
  {
   OnSomethingHasHappened(this, new EventArgs()); 
  }
 }
}

和订阅者类:

public class Subscriber()
{
 public Subscriber()
 {
  Car car = new Car();
  car.OnSomethingHasHappened += Car_SomethingHasHappened();
 }

 // is this named correctly?
 private void Car_SomethingHasHappened(object sender, EventArgs e)
 {
  // do stuff
 }
}

提前致谢!

几乎

触发事件的方法 – On< When> Event(from RaiseSomethingHasHappened)

即OnBeforeOpen,OnClosing,OnSomethigHasHappened

事件< When> Event(from OnSomethingHasHappened)

即开始之前,关闭,某事已经出现

处理程序<实例或有意义的名称>< _><事件> (来自Car_SomethingHasHappened)

即Form_BeforeOpen,Window_Closing,Car_SomethingHasHappened – >完善

转载注明原文:正确命名C#事件和处理程序[已关闭] - 代码日志