ASP.Net-公共类中的条件

ASP.Net-公共类中的条件,asp.net,class,conditional-statements,Asp.net,Class,Conditional Statements,我在下面有一个公共类,我想包括一个条件,把它放在里面,它不工作。有什么建议吗 public SummaryDates GetSummaryDates() { SummaryDates result = new SummaryDates(); var getDay = 3; DateTime now = DateTime.UtcNow.Date; var getMonth = 0; var getQuarte

我在下面有一个公共类,我想包括一个条件,把它放在里面,它不工作。有什么建议吗

public SummaryDates GetSummaryDates()
    {

        SummaryDates result = new SummaryDates();
        var getDay = 3;
        DateTime now = DateTime.UtcNow.Date;
        var getMonth = 0;
        var getQuarter = 0;
        var quarterNow = now.AddMonths(3 * getQuarter);
        var quarterNumber = Math.Ceiling(quarterNow.Month / 3m);

        var quarterLabel2 = 0;
        var quarterLabel1 = 0;
        var quarterLabelA = 0;
        var quarterLabelB = 0;

        result.summaryDates = new SummaryDates
        {
           startOfQuarter2 = now,
            endOfQuarter2 = now,
            endOfQuarter2Plus1Day = now,
            endOfQuarter1Plus1Day = now,
            startOfQuarter1 = now,
            endOfQuarter1 = now,
            startOfQuarterA = now,
            startOfQuarterB = now,
            endOfQuarterA = now,
            endOfQuarterB = now,
            endOfQuarterAPlus1Day = now,
            endOfQuarterBPlus1Day = now,

    if (quarterNumber == 4)
        {
            startOfQuarter2 = new DateTime(getSummaryDates.quarter2Year, 10, 01);
            endOfQuarter2 = new DateTime(getSummaryDates.quarter2Year, 12, 31);
            endOfQuarter2Plus1Day = getSummaryDates.endOfQuarter2.AddDays(1);
            quarterLabel2 =  Convert.ToInt16(Math.Ceiling(getSummaryDates.endOfQuarter2.Month / 3m));

}
        return result;
       }
    }

我已经把条件放进去了。它不起作用。

它应该起作用。有什么错误吗?startOfQuarter2=(quarterNumber==4)?现在:新的日期时间(getSummaryDates.quarter2Year,10,01)如果它有4个条件呢?