Lets try converting the program from string to int,float ,double,char
To interger "Convert.ToInt32(inputed value)";
To float we use "float.Parse(inputed value)",
To double "Convert.ToDouble(inputed value)",
To Character "Convert.ToChar(inputed value)"
using System;
{
class cls1
{
static void Main()
{
String str;
int inum;
Console.WriteLine(" Enter a number");
str=Console.ReadLine();
inum=Convert.ToInt32(str); // Here we are converting
Console.WriteLine("The numbe entred is "+inum);
}
}
}

No comments:
Post a Comment