1. 数据类型
C++
C++ 值类型
整数:
shortintlonglong longunsigned shortunsigned intunsigned longunsigned long long小数:
floatdoublelong double布尔:
bool字符:
char(8位)wchar_t(16位宽字符)char16_t(UTF-16)char32_t(UTF-32)
RUST
Rust 值类型
整数:
i8i16i32i64isizei128u8u16u32u64u128usize小数:
f32f32布尔:
bool字符:
char(UTF-32字符)
C#
C# 值类型
整数:
bytesbyteshortushortintuintlongulongnintnuint小数:
floatdoubledecimal布尔:
bool字符:
char(UTF-16字符)
C# 引用类型
object string dynamic
python
python 值类型
golang
golang 值类型
整数:
intint8int16int32int64uintuint8uint16uint32uint64uintptr小数:
float32float64复数:
complex64complex128布尔:
bool
byte// uint8 别名
rune// int32 别名 UTF-32字符字串:
string
Julia
Julia 值类型
整数:
Int8Int16Int32Int64Int128UInt8UInt16UInt32UInt64UInt128小数:
Float16Float32Float64布尔:
Bool字符:
Char(UTF-32字符)
Swift
Swift 值类型
整数:
Int8Int16Int32Int64Int128UInt8UInt16UInt32UInt64UInt128IntUInt小数:
FloatDouble布尔:
Bool字符:
Character
2. 变量常量
Rust
let x = "你好世界"; // 申明不可变量
let mut x; // Shadow x 可声明为不同的类型
x = 1; // 赋值 并推断类型为 i64 const Y: bool = true & false; // 常量 Y 在整个作用域可见
{
let x = x; // x = 2; // 错误, frozen x 为不可变量
}
x = 3; // 正确, x 解封
C#
string username = "YSH";
int age = 33;
var isMale = true;
const long birthYear = 1988;
dynamic any = new DateTime();
python
golang
var username string = "YSH"
var age = 33
isMage := true
const birthYear = 1988