【发布时间】:2015-07-21 23:05:23
【问题描述】:
我有这样的课程:
public class TestResults
{
public String TestName {get;set;}
public Int32 StudentID {get;set;}
public Decimal Score {get;set;}
public Date TestTaken {get;set;}
}
所以有些对象 mike 看起来像这样:
test.TestName = "Big Important Test";
test.StudentID = 17;
test.Score = 0.75M;
test.TestTaken = "1/1/2015";
tests.add(test);
test.TestName = "Big Important Test";
test.StudentID = 12;
test.Score = 0.89M;
test.TestTaken = "1/1/2015";
tests.add(test);
test.TestName = "Sneaky Pop Quiz in Chemistry";
test.StudentID = 17;
test.Score = 0.97M;
test.TestTaken = "2/1/2015";
tests.add(test);
test.TestName = "Sneaky Pop Quiz in Chemistry";
test.StudentID = 17;
test.Score = 0.97M;
test.TestTaken = "2/1/2015";
tests.add(test);
我试图确定的是“对于每个学生,向我展示他们的分数大幅提升的学生?” I asked a similar question a while back in the dba.stackexchange.com world 并使用了 LEAD 函数,但现在我想将逻辑移到 C# 中。
所以我想编写的一个具体问题是(例如):
告诉我从 60% 和 70% 范围跳到 90 范围。
我知道我可以写一个rat's nest of loops and branching logic,但想知道是否有任何更优雅、更全面的方法来识别 LINQ/C# 领域中的模式序列。
我听人谈论过 F#,但没有这方面的实际经验。此外,我认为我所说的“模式匹配”比我经常遇到的一些simple string-pattern-matching 涉及更多。
【问题讨论】:
标签: c# linq pattern-matching sequence