我正在尝试使用string
将form SettingsMenu
从Delegate
发送到我的主表单,其结构如下所示:
在SettingsMenu窗体上进行委托:
delegate void ClocknameReceivedEventHandler(object sender, SettingsMenu.ClocknameReceivedEventArgs e);
SettingsMenu类中的内部类ClocknameReceivedEventArgs:
public partial class SettingsMenu : Form
{
internal class ClocknameReceivedEventArgs : EventArgs
{
string _clockname;
public string Clockname
{
get { return _clockname; }
}
public ClocknameReceivedEventArgs(string clockname)
{
_clockname = clockname;
}
}
}
在
SettingsMenu
中的代码还有一点点下降:public event ClocknameReceivedEventHandler ClocknameReceived;
// Invoke the Changed event; called whenever list changes
protected void OnClocknameReceived(SettingsMenu.ClocknameReceivedEventArgs e)
{
ClocknameReceived(this, e);
}
我使用以下
SettingsMenu
从Main form
上的Event
捕获传入的数据:_settings.ClocknameReceived += new ClocknameReceivedEventHandler(ClockClocknameReceived);
我的Main窗体上的实际从SettingsMenu接收字符串的方法:
private void ClockClocknameReceived(object sender, SettingsMenu.ClocknameReceivedEventArgs e)
{
string ClockName;
ClockName = e.Clockname;
lblClockname.Text = ClockName;
}
现在,在SettingsMenu类中出现以下错误:
Error 2 Inconsistent accessibility: parameter type 'LivePigeonClient.Forms.SettingsMenu.ClocknameReceivedEventArgs' is less accessible than method 'LivePigeonClient.Forms.SettingsMenu.OnClocknameReceived(LivePigeonClient.Forms.SettingsMenu.ClocknameReceivedEventArgs)' D:\SVN\sentul\Livepigeonflights\trunk\LivePigeonClientSolution\LivePigeonClient\Forms\SettingsMenu.cs 54 24 LivePigeonClient
和
Error 1 Inconsistent accessibility: field type 'LivePigeonClient.Forms.ClocknameReceivedEventHandler' is less accessible than field 'LivePigeonClient.Forms.SettingsMenu.ClocknameReceived' D:\SVN\sentul\Livepigeonflights\trunk\LivePigeonClientSolution\LivePigeonClient\Forms\SettingsMenu.cs 51 52 LivePigeonClient
谁能告诉我我做错了什么?
最佳答案
我需要使用public delegate
和public class
来解决问题。
关于c# - 使用代理的可访问性不一致,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15427761/