public class KeyEvent {
private Keys[] keys = null;
public delegate void eventmethod();
private eventmethod em;
private object[] args;
private bool thrown = false;
public bool repeat = true;
public bool isKey(Keys key) {
if (keys == null) return true;
foreach (Keys k in keys) {
if (key == k) return true;
}
return false;
}
public void ThrowEvent() {
if (!repeat && thrown) return;
em.DynamicInvoke(args);
this.thrown = true;
}
public KeyEvent(eventmethod D) {
em = D;
}
public KeyEvent(Keys[] keys, eventmethod D) {
this.keys = keys;
this.KeyEvent(D);
}
public KeyEvent(eventmethod D, object[] args) {
this.args = args;
this.KeyEvent(D);
}
public KeyEvent(Keys[] keys, eventmethod D, object[] args) {
this.args = args;
this.KeyEvent(keys, D);
}
}
Hey, guys; this class won’t compile. The error I’m getting is:
‘BLBGameBase.KeyEvent’ does not
contain a definition for ‘KeyEvent’
and no extension method ‘KeyEvent’
accepting a first argument of type
‘BLBGameBase.KeyEvent’ could be found
(are you missing a using directive or
an assembly reference?)
Anyway, this error is thrown for the three lines that call “this.KeyEvent(D)” or similar.
I don’t understand the error, as it argues that no method accepts a first argument of a “KeyEvent”, but I’m not trying to call a method with a KeyEvent… Thank you.
To call one constructor from another, use this syntax:
As your code stands, it is trying to call a regular method (non-constructor) called
KeyEvent.