Array of UInt16, what is the suffix in C #?

I am trying to initialize an inline array of UInt16. For int, I can do the following:

int[] int_array = new[]{0,0,0,0};

Meanwhile, using UInt16 does not work without a cast:

UInt16[] uint16_array= new[]{(UInt16)0,(UInt16)0};

This is pretty annoying to these castes. I was wondering if there is any kind of suffix in C # to eliminate the ambiguity of assignment (e.g. 0.0f for float).

+5
source share
4 answers

I don't think there is one, but why don't you do it instead

UInt16[] uint16_array= new UInt16[] { 0, 0, 0, 0 };
+16
source

C # does not have a type suffix for unsigned 16-bit integers. VB.NET though, for reference only:

Dim number As UShort = 8US

Here is another resource listing the various suffixes.

+4

, :

ushort[] uint16_array = { 0, 0, 0, 0 };

()

UInt16[] uint16_array = { 0, 0, 0, 0 };
+2

All Articles