using nullable types


T

Tony Johansson

Hello!

This construction
int? op1 = 5;
int result = op1 * 2;

gived a compile error with
Error 1 Cannot implicitly convert type 'int?' to 'int'. An explicit
conversion exists (are you missing a cast?)
C:\tony\ConsoleApplication1\ConsoleApplication1\Program.cs 12 26
ConsoleApplication1

If I instead have this construction
int? op1 = 5;
int result = op1 * 2 ?? 12;
Then no compile error will occur.

I mean that because I don't have a nullable type for result it should
give a compile error as the first example did.

//Tony
 
Ad

Advertisements


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

Top