如何在C#中访问受保护的方法

时间:2011-12-04 16:48:06

标签: c# methods protected access-modifiers awesomium

我想知道如何访问受保护的方法。

我有一个WebBrowser控件(Awesomium),它有许多受保护的方法。

我在WinForm中使用此WebControl创建了一个选项卡式浏览器。

现在我不能使用ie InjectKeyboard - 方法导致它受到保护。

这是方法:

//     Injects a keyboard event.
//
// Parameter:
//   keyEvent:
//     The keyboard event to inject. You'll need to initialize the members of the
//     passed Awesomium.Core.WebKeyboardEvent, yourself.
//
// Note:
//      Awesomium.Windows.Forms.WebControl handles this internally. Inheritors do
//     not need to call this method unless they implement custom logic.  This method
//     bypasses settings of the Awesomium.Windows.Forms.WebControl.InputController.
//      For performance reasons, no validity check is performed when calling protected
//     members.  Inheritors should perform any such checks (see Awesomium.Windows.Forms.WebControl.IsLive),
//     before calling these members.

protected void InjectKeyboardEvent(WebKeyboardEvent keyEvent);

在API链接中HERE

他们为什么要保护这种方法?我该如何使用它?

1 个答案:

答案 0 :(得分:1)

继承此类并在需要时公开该方法(由方法上方的注释提出)。