我正在尝试在我的 Windows 服务的主类中定义一个属性。该属性将用于在需要时检索进程的名称。
例如:
public string PName
{
return SomeProcess.Name;
}
public string PID
{
return SomeProcess.ProcessId;
}
public Process SomeProcess
{
private Process[] myProcess = Process.GetProcessesByName("notepad"); //Process is underlined here with red wavy line saying "A get or set accessor method is expected"
get
{return myProcess[0];}
}
问题出在注释中写的 SomeProcess 属性中。我在这里做错了什么?