Solution:
using System;
class Program {
static void Main(string[] args) {
// Demonstrate primitive data types
bool isTrue = true;
char letter = 'a';
int number = 10;
float decimalNumber = 3.14f;
double bigDecimalNumber = 99999999.99999999;
decimal preciseDecimalNumber = 1.23456789m;
Console.WriteLine("Boolean: " + isTrue);
Console.WriteLine("Character: " + letter);
Console.WriteLine("Integer: " + number);
Console.WriteLine("Float: " + decimalNumber);
Console.WriteLine("Double: " + bigDecimalNumber);
Console.WriteLine("Decimal: " + preciseDecimalNumber);
// Convert integer to string
int intNumber = 123;
string strNumber = intNumber.ToString();
Console.WriteLine("Integer converted to string: " + strNumber);
// Convert string to integer
string strNumber2 = "456";
int intNumber2 = Int32.Parse(strNumber2);
Console.WriteLine("String converted to integer: " + intNumber2);
}
}
0 Comments