Data Types
Type Conversion
Conversion changes a value from one type to another when the program needs a different form.
Type Conversion
TypeConversion.cs
using System;
class Program
{
static void Main()
{
string text = ;
int value = int.Parse(text);
int doubled = value * 2;
Console.WriteLine($"text={text}");
Console.WriteLine($"value={value}");
Console.WriteLine($"doubled={doubled}");
}
}
using System;
class Program
{
static void Main()
{
string text = ;
int value = int.Parse(text);
int doubled = value * 2;
Console.WriteLine($"text={text}");
Console.WriteLine($"value={value}");
Console.WriteLine($"doubled={doubled}");
}
}
using System;
class Program
{
static void Main()
{
string text = ;
int value = int.Parse(text);
int doubled = value * 2;
Console.WriteLine($"text={text}");
Console.WriteLine($"value={value}");
Console.WriteLine($"doubled={doubled}");
}
}
parse
Parsing converts text into a typed value such as an integer.