Windows Phone Developers

Saturday, October 11, 2008

Literal of type double cannot be implicitly converted to type 'decimal'; use an 'M' suffix to create a literal of this type

An assignment could not be completed; use a suffix to correct the instruction. The documentation for each type identifies the corresponding suffix for the type.

private void conversion_example()

{

int ivar = 1000;

decimal dvar = 0.15;

decimal ret_val;

ret_val = ivar * dvar;

}

Solution

private void conversion_example()

{

int ivar = 1000;

decimal dvar = 0.15M;

decimal ret_val;

ret_val = ivar * dvar;

}



Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

2 comments:

  1. ¿Why added the M suffix in this case?

    decimal[] importeTotal = new decimal[] { 999.9, 324.2, 0.0, 222.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

    Regards.

    ReplyDelete