The following table lists the primitive types in Rust and their equivalent in C# and .NET:
|See note 1.
|See notes 2 & 3.
|See note 3.
charin Rust and
Charin .NET have different definitions. In Rust, a
charis 4 bytes wide that is a Unicode scalar value, but in .NET, a
Charis 2 bytes wide and stores the character using the UTF-16 encoding. For more information, see the Rust
While a unit
()(an empty tuple) in Rust is an expressible value, the closest cousin in C# would be
voidto represent nothing. However,
voidisn't an expressible value except when using pointers and unsafe code. .NET has
ValueTuplethat is an empty tuple, but C# does not have a literal syntax like
()to represent it.
ValueTuplecan be used in C#, but it's very uncommon. Unlike C#, F# does have a unit type like Rust.
objectare not scalar types (even though scalars like
intare sub-classes of
objectin the .NET type hierarchy), they have been included in the above table for convenience.