我一直很难编写一种更简单和/或精简的方法来重写此方法。这是c#中使用的方法。有没有一种方法可以简化或压缩此代码以使其更易于理解?
C#:
private void prepareToPrint()
{
teams.Clear();// Clearing the list of teams
//Storing the teams and information in the List
foreach (DataRowView row in bindingSource1.List)
{
//Checking if information is true
if ((combobox1.Text == "All Teams" || combobox1.Text == row["Home Team"].ToString()
|| combobox1Text == row["Away Team"].ToString())
&& (DateTime)row["Game_Date"] >= datebeg.Value &&
(DateTime)row["Game_Date"] <= dateEnd2.Value)
{
short hScore = (short)row["Home Pts Scored"];
short aScore = (short)row["Away Pts Scored"];
string home = row["Home Team"].ToString();
string away = row["Away Team"].ToString();
DateTime date = (DateTime)row["Game_Date"];
teamInfo teamStuff = new teamInfo(hScore, aScore, home, away, date);
teams.Add(teamStuff);
}
}
}