Why can’t you assign a number with a decimal point to the decimal type directly without using type suffix? isn’t this kind of number considered a number of type decimal?
decimal bankBalance = 3433.20; // ERROR!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Edit: I may have missed the last part of the question, so the overview below is hardly useful.
Anyway, the reason you can’t do what you’re trying to do is because there is no implicit conversion between floating point types and
decimal. You can however assign it from an integer, as there is an implicit conversion from int to decimal.You can, but you have to use this syntax (or do an explicit cast to decimal).
and for floats it is
default is double