@{ var auction = new mvcauction.models.auction() { title = "example auction", description = " example auction ", starttime = datetime.now, endtime = datetime.now.adddays(7), startprice = 1.00m, currentprice=null;` }; } <div class ="auction" /> <h3>@auction.title</h3> <div class="details"></div> <p> starttime : @auction.starttime.tostring("g")</p> <p> endtime:@auction.endtime.tostring("g")</p> <p>startingprice : @auction.startprice.tostring("c")</p> <p> currentprice: @if (auction.currentprice == null) { @: [no bids] } else { <span>@auction.currentprice.value.tostring("c")</span> } </p>
when running code in visual studio 2012 gives me error error cs0037: cannot convert null 'decimal' because non-nullable value type
>error cs1061: 'decimal' not contain definition 'value' , no extension method 'value' accepting first argument of type 'decimal' found (are missing using directive or assembly reference?)
c# case-sensitive language. need capital v in value
. , tostring
needs camel case. allow code compile.
@auction.currentprice.value.tostring("c")
Comments
Post a Comment