SEARCH C# PROGRAMMING CODES HERE

Convert-Methods

Convert-Methods in C#.
Convert Methods are used for converting data type values for the specified signed types so let's see some of them which are used to convert from specified type to signed integer as 16bit,32bit,64 as follows.

















1-Convert.ToInt16(); Method in C#
This strategy is utilized to converts the specified data type to an equivalent 
16-bit signed integer. 
So let's see the example which demonstrates Convert.ToInt16 method as shown below.

using System;

namespace ToInt16_program
{
    class program
    {
        static void Main(string[] args)
        {
            double f=12345.055; 

            /* converting double to specified int */
            int value = Convert.ToInt16(f);

            /* Display the converted float value */
            Console.Write("Float value ="+f+"\n Converted to Int_16_bit={0} ", value,f); 
            Console.ReadKey();
        }
    }
}

      Output
















2-Convert.ToInt32(); Method in C#
This strategy is utilized to converts the specified data type to an equivalent 32-bit signed integer. So let's see the example which demonstrates Convert.ToInt32();method as shown below.
Program
using System;

namespace ToInt32_program
{
    class program
    {
        static void Main(string[] args)
        {
            double f=1234567890.054565;

            /* converting double to specified int */
            int value = Convert.ToInt32(f);

            /* Display the converted float value */
            Console.Write("float value= "+f+"\nConverted to Int_32_bit={0} ", value,f); 
            Console.ReadKey();
        }
    }
}

      Output















3-Convert.ToInt64(); Method in C#
This strategy is utilized to converts the specified data type to an equivalent 64-bit signed integer. 
So let's see the example which demonstrates Convert.ToInt64();method as shown below.
Program
using System;

namespace ToInt64_program
{
    class program
    {
        static void Main(string[] args)
        {
          double f=123456789012345678.555;

            /* converting double to specified int */
           long value = Convert.ToInt64(f);

            /* Display the converted float value */
            Console.Write("float value= "+f+"\nConverted to Int_64_bit={0} ", value,f); 
            Console.ReadKey();
        }
    }
}

 Output