Einzelnen Beitrag anzeigen

OregonGhost

Registriert seit: 8. Jun 2002
Ort: Lübeck
1.216 Beiträge
 
Delphi 3 Professional
 
#2

Re: [C#] Constructor chaining

  Alt 15. Aug 2008, 12:16
Auf Anhieb wüsste ich nur eine etwas unsaubere Lösung mithilfe einer Utilty-Funktion, z.B.
Code:
IntPtr HandleFromControl(Control control)
{
    if (control != null) {
        return control.Handle;
    }
    throw new ArgumentNullException("control");
}
und dann im Konstruktoraufruf eben
Code:
public GlobalHotkey(Control control): this(HandleFromControl(control)) {}
Oregon Ghost
---
Wenn NULL besonders groß ist, ist es fast schon wie ein bisschen eins.
  Mit Zitat antworten Zitat