私の必要性は、四半期ごとにシェアポイントリストからデータを取得することです。つまり、開始日と終了日をパラメーターとして渡し、開始日の月を取り、四半期を計算する必要があります。つまり、2012 年 2 月 5 日を開始日として渡すとします。その後、四半期は 2 月 3 月 4 月から始まり、残りの月も同様に、
ここで、2012 年の 12 月、2013 年の 1 月と 2 月が四半期で構成されていると想像してください。私の場合、12 月のデータは四半期を構成し、1 月と 2 月は別の四半期を構成する必要があります。
車の出力名と、四半期の車の総数を表示する必要があります。クラスの定義は次のようになります。
public class Foo
{
public int quantity { get; set; }
public string cars { get; set; }
public DateTime date { get; set; }
}
List<Foo> lst = new List<Foo>();
lst.Add(new Foo { date = Convert.ToDateTime("31/Dec/2011"), cars = "cars1", quantity = 20 });
lst.Add(new Foo { date = Convert.ToDateTime("31/Dec/2011"), cars = "cars2", quantity = 30 });
lst.Add(new Foo { date = Convert.ToDateTime("1/Jan/2012"), cars = "cars2", quantity = 80 });
lst.Add(new Foo { date = Convert.ToDateTime("11/Feb/2012"), cars = "cars1", quantity = 10 });
lst.Add(new Foo { date = Convert.ToDateTime("29/Feb/2012"), cars = "cars3", quantity = 7 });
lst.Add(new Foo { date = Convert.ToDateTime("29/May/2012"), cars = "cars3", quantity = 1 });