C# example
public Employee GetEmployee(string strName) { Employee objEmployee = null; if (strName != "" && strName != null) { for (int i = 0; i < m_arrEmployeeCollection.Count; i++) { if (strName == m_arrEmployeeCollection[i].Name) { objEmployee = m_arrEmployeeCollection[i]; break; } } } return objEmployee; }
Rule: Exit the loop if expected condition is met.
No comments:
Post a Comment