基本类型

类型初始化

using System;

//"const" + 类型名用于常量,
//"var" 或类型名用于变量

//整数
int number = 42, otherNumber = 37;
const ulong maxInt64 = ulong.MaxValue;
const int Mb = 1_048_576;

//双精度浮点数
const double exp = 2.71828;
double billion = 1E+9;

//单精度浮点数
const float pi = 3.14f;

//字符串
const string greeting = "Hello";

//多行字符串
var text = @"this is some
multiline text";

//布尔值
const bool sunIsStar = true;
var earthIsStar = false;

//字符 "A"
const char charA = 'A'; //'\x0041'; (char)65; '\u0041'

//元组 (Int, String)
var one = (1, "one");

Console.WriteLine($"number = {number}");
Console.WriteLine($"otherNumber = {otherNumber}");
Console.WriteLine($"maxInt64 = {maxInt64}");
Console.WriteLine($"Mb = {Mb}");
Console.WriteLine($"exp = {exp}");
Console.WriteLine($"billion = {billion}");
Console.WriteLine($"pi = {pi}");
Console.WriteLine($"greeting = {greeting}");
Console.WriteLine($"text = {text}");
Console.WriteLine($"sunIsStar = {sunIsStar}");
Console.WriteLine($"earthIsStar = {earthIsStar}");
Console.WriteLine($"charA = {charA}");
Console.WriteLine($"one = {one}");