object obj = false ? 0.3 : 1;

  • Thread starter Thread starter bob
  • Start date Start date
B

bob

Hello,

in this line:
object obj = false ? 0.3 : 1;

why does obj end up being a boxed double {1.0}

Seems strange to me
 
Hi bob,

This is because 0.3 is a double, and both sides of the : must be of the
same type, so 1 is converted to 1.0;

Happy coding!
Morten Wennevik [C# MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top