Tuesday, 28 May 2019

Miscellaneous_ and sizeof function_used_C# Program


Miscellaneous_ and sizeof function_used_Program


using System;
namespace Miscellaneous_operator_used_Program
{
    class Program
    {
        static void Main(string[] args)
        {
            /*extra programs */
            Console.WriteLine("The size of in is={0}",sizeof(int));
            Console.WriteLine("The size of in is={0}", sizeof(short));
            Console.WriteLine("The size of in is={0}", sizeof(double));

            /* Example of ternary operator */

            int a, b;
            a = 10;
            b = (a ==1) ? 20 : 30;
            Console.WriteLine("Value of b is ={0}",b);

            b = (a == 10) ? 20 : 30;
            Console.WriteLine("Value of b is ={0}", b);
            Console.ReadKey();
        }
    }
}


No comments:

Post a Comment