how do I convert if else to one line if else?

Posted by roozbeh heydari on Stack Overflow See other posts from Stack Overflow or by roozbeh heydari
Published on 2013-11-04T10:27:33Z Indexed on 2013/11/04 21:54 UTC
Read the original article Hit count: 332

Filed under:
|

how do i convert follow code to one line if else

if (data.BaseCompareId == 2)
    report.Load(Server.MapPath("~/Content/StimulReports/MonthGroup.mrt"));
else
    report.Load(Server.MapPath("~/Content/StimulReports/YearGroup.mrt")); 

i try this code but did not work

data.BaseCompareId == 2
    ? report.Load(Server.MapPath("~/Content/StimulReports/MonthGroup.mrt"))
    : report.Load(Server.MapPath("~/Content/StimulReports/YearGroup.mrt"));

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc