Showing posts with label Decimal to int Datatype Conversion. Show all posts
Showing posts with label Decimal to int Datatype Conversion. Show all posts

Thursday, April 28, 2016

Decimal to int Datatype Conversion

using System;
namespace TypeConversionApplication 
{
 class ExplicitConversion 
 {
 static void Main(string[] args) 
 {
 decimal a = 10.0M;
 int b = Convert.ToInt32(a);
 Console.WriteLine(b);
 Console.ReadKey();
 }
 }
}
Output : 10

Decimal to Float Datatype Conversion

using System;
namespace TypeConversionApplication 
{
 class ExplicitConversion 
 {
 static void Main(string[] args) 
 {
 decimal a = 20.0M;
 float b = Convert.ToSingle(a);
 Console.WriteLine(b);
 Console.ReadKey();
 }
 }
}
Output : 20