using System;
class Program
{
static void Main()
{
//Implicit Conversion
//1.When there is no loss of information if the conversion is done
//2. If there is no possibility of throwing exceptions during the conversion
/*int i = 100;
float f = i;
Console.WriteLine(f); */
//Explicit Convertion
/* float f = 123.45F;
int i = Convert.ToInt32(f); //Convert function
//int i = (int)f; //type cast operator <- occur losing part\
*/
/*float f = 127373343433.35F;
//int i = Convert.ToInt32(f); //throwing exceptions (overflow)
int i = (int)f; //not throwing exceptions
Console.WriteLine(i);*/
//string to int - Parse() , TryParse()
//Parse() : throw an exception
//TryParse() : returns a boll indicating whether it succeeded or failed
string strNumber = "100TG";
//int i = int.Parse(strNumber);
int Result = 0;
bool IsConversionSuccessful = int.TryParse(strNumber, out Result);
if (IsConversionSuccessful)
{
Console.WriteLine(Result);
}
else
{
Console.WriteLine("Please enter a valid number");
}
}
}