Entirely redundant C# 2.0 code
The only benefit of this is Range accepts start > end, so I could equally well doprivate static IEnumerable< int> Range ( int start, int end )
{
for ( int i = start; i != end; i = (start > end ) ? i - 1 : i + 1 )
{
yield return i;
}
yield return end;
}
private void PopulateDaysDropDown ( )
{
foreach ( int day in Range ( 1 , 31 ) )
{
DateOfBirthDay.Items.Add ( day.ToString ( ) );
}
}
foreach ( int day in Range ( 31, 1 ) ) { //... }
I'm determined to find a valid use for yield return somewhere!
No comments:
Post a Comment