Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

array of UInt16, what's the suffix in C#?

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

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

meanwhile using UInt16 doesn't work without a cast:

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

It's quite annoying do those casts. I was wondering if there is any suffix in C# to disambiguate the assignment (like 0.0f for float).

like image 211
Heisenbug Avatar asked Nov 07 '11 20:11

Heisenbug


1 Answers

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

UInt16[] uint16_array= new UInt16[] { 0, 0, 0, 0 };
like image 117
Corey Kosak Avatar answered Oct 06 '22 02:10

Corey Kosak