none
How can the result be displayed with the data type short? RRS feed

  • Question

  •   {
            static void Main(string[] args)
            {   
                short num1 = 3;
                short  num2 = 4;
                short result ;
                result =(num1 + num2);
                Console.WriteLine(""+result); 
            }
        }

    Sunday, October 15, 2017 12:20 PM

All replies

  • Try this:

    result = (short)( num1 + num2 );
    Console.WriteLine( result );

    or change the type of result to int.


    • Edited by Viorel_MVP Sunday, October 15, 2017 1:28 PM
    • Proposed as answer by Fei HuModerator Thursday, October 19, 2017 11:02 AM
    Sunday, October 15, 2017 1:26 PM
  • Hello MUGHAL153,

    Is there anything updated?  If the issues has been solved, you could close the thread by marking the reply as answer, This can be beneficial to other community members reading this thread.

    Sincerely,
    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Sunday, October 29, 2017 7:49 AM
    Moderator