Created
August 14, 2016 11:30
-
-
Save demofan/62adf0b36a5ac03c37e82ea9e39beed3 to your computer and use it in GitHub Desktop.
yield return 示範
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var testSource = LookUp(); | |
testSource.Dump(); | |
} | |
IEnumerable<DepositModels> LookUp() | |
{ | |
for (int i = 0; i < 3; i++) | |
{ | |
yield return new DepositModels | |
{ | |
Category = i, | |
Date = DateTime.UtcNow.AddDays(i), | |
Money = i & 1000 | |
} | |
} | |
} | |
class DepositModels | |
{ | |
public int Category { get; set; } | |
public DateTime Date { get; set; } | |
public int Money { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment