我想在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屬性裏面。我在這裏做錯了什麼?