Practice mode C#

Which suffix must be added to the literal 9.99 to assign it to a decimal variable in C#?

Correct answer C. m

Explanation

A real literal such as 9.99 is a double by default, and there is no implicit conversion from double to decimal, so decimal price = 9.99; does not compile. Writing 9.99m makes it a decimal literal. The suffix f marks a float, d an explicit double and L a long integer. The m is often remembered as standing for money.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.