Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

「int16」 converted into 「int32」 implicitly

$
0
0
The following segment of code kind of confused me .

        private void button1_Click(object sender, EventArgs e)
        {
            Int16 nTemp = 1;
            NumberTest(nTemp + 1);
        }
        private void NumberTest(Int16 v_nValue)
        {
            MessageBox.Show(v_nValue.ToString());
        }



When I was trying to compile these code , the vS2010 throw an error about type int16 cannot convert into short.

But it seems like the same type.

So I took a test about it.


private void button1_Click(object sender, EventArgs e)
        {
            Int16 nTemp = 1;
            MessageBox.Show((nTemp + 1).GetType().ToString());
        }




The type what I got is 「int32」!

Could someone tell me what it is happening ??

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>