2
     @{
        var auction = new MvcAuction.Models.auction()
        {
        Title = "Example Auction",
        Description = " This is an 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 i am running this code in visual studio 2012 it gives me an error error CS0037: Cannot convert null to 'decimal' because it is a non-nullable value type

>error CS1061: 'decimal' does not contain a definition for 'value' and no extension method 'value' accepting a first argument of type 'decimal' could be found (are you missing a using directive or an assembly reference?)
1
  • i am learnin asp.net mvc 4 and this code is an example in a video and it is supposed to run as the video shows but it gives me the same error every time Commented Jan 24, 2016 at 21:23

1 Answer 1

2

C# is a case-sensitive language. You need Capital V in Value. And ToString needs to be camel case. This will allow the code to compile.

@auction.CurrentPrice.Value.ToString("c")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.