您可以使用枚舉:enum StatusRouter { Stop = 0, Start, Resume, Suspect };
如何將這4個函數轉換爲一個?
public bool StartSelectedRouter()
{
for (int i = 0; i < m_listPlatforms.Count; i++)
{
if (m_listPlatforms[i].IsCheked)
m_listPlatforms[i].Start();
}
return false;
}
public bool ResumeSelectedRouter()
{
for (int i = 0; i < m_listPlatforms.Count; i++)
{
if (m_listPlatforms[i].IsCheked)
m_listPlatforms[i].Resume();
}
return false;
}
public bool SuspendSelectedRouter()
{
for (int i = 0; i < m_listPlatforms.Count; i++)
{
if (m_listPlatforms[i].IsCheked)
m_listPlatforms[i].Suspend();
}
return false;
}
public bool StopSelectedRouter()
{
for (int i = 0; i < m_listPlatforms.Count; i++)
{
if (m_listPlatforms[i].IsCheked)
m_listPlatforms[i].Stop();
}
return false;
}
有什麼問題嗎? – CodesInChaos
如何將這四個函數轉換爲一個? – Mediator
'家庭作業'標籤在哪裏? –