Sunday, May 1, 2016

Float to int Datatype Conversion

using System;
namespace TypeConversionApplication 
{
 class ExplicitConversion 
 {
 static void Main(string[] args) 
 {
 float a = 70.0f;
 int b = Convert.ToInt32(a);
 Console.WriteLine(b);
 Console.ReadKey();
 }
 }
}
Output : 70

String to int Datatype Conversion

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

No comments: