我期待每次在我的類中設置屬性時觸發一個事件。我希望能夠觸發這個相同的事件,只要我的一個屬性被設置。我有(其中大約12個)C#:爲GET/SET屬性上的類創建事件
即,
public class MyClass
{
private int _myHeight;
private int _myWidth;
public int myHeight
{
get { return myHeight; }
set { myHeight = value;
//This fires event!
}
}
public int myWidth
{
get { return myWidth; }
set { myWidth = value;
//This will fire the same event!
}
我對事件本身並不陌生,但對創建事件來說卻是新事物。我一直使用Windows應用程序中使用的'開箱即用'事件。有任何想法嗎?
看看這個問題它就是你在爲什麼http://stackoverflow.com/questions/2264533/listener-c-like-java/2264547#2264547 – IordanTanev 2010-02-20 16:33:00