// create iterator method
public IEnumerable<decimal?> BucketIterator(Accounts_basic a ) {
int cycle = 0;
for (int i=7 ; i > 0 ; i--){
switch (i) {
case 1:yield return a.dd_15;break;
case 2 :yield return a.dd_30; break;
case 3:yield return a.dd_60; break;
case 4:yield return a.dd_90; break;
case 5 :yield return a.dd_120; break;
case 6:yield return a.dd_150; break;
case 7:yield return a.dd_180; break;
default : yield break;
}
}
// use iterator method as follows
foreach (decimal? amount in BucketIterator(accounts_basic)) {
// use amount here
}
No comments:
Post a Comment