BanksySan
BanksySan

Reputation: 28510

What is the correct word for a type shorthand in .NET?

For example:

100M is decimal
100l is long

I wanted to find one for a unit, so I don't have to type (uint) 123 all the time and I realised I didn't know what word to search for.

Upvotes: 0

Views: 159

Answers (4)

Jon Skeet
Jon Skeet

Reputation: 1500873

If you're just talking about terminology, literal is a value specified directly in source, such as:

10 10M 100L "this is a regular string literal" @"this is a verbatim string literal" '\u000' '\n' 'X'

A numeric literal can include a suffix (l/L, u/U, ul/UL, m/M, f/F, d/D) to give more information about the type of value being represented.

In terms of the literal suffix for uint, it's U or u. This works for both uint and ulong in fact; a literal value smaller than or equal to unit.MaxValue will be implicitly uint; a larger value will be implicitly ulong. See MSDN or the C# language spec section 2.4.4 for more details.

Upvotes: 6

Iddillian
Iddillian

Reputation: 195

The word you are looking for is Literal. For example the Literal suffix for uint(as everyone has said) is U. so you would have 123U.

Upvotes: 0

BanksySan
BanksySan

Reputation: 28510

Had a brain wave. It's a literal

100l, 100m, 100u etc are all literals.

Upvotes: 0

rkawano
rkawano

Reputation: 2503

For UInt you can use 'U' char:

uint i = 123U;

Reference

Upvotes: 1

Related Questions