forum

home / developersection / forums / two dimensional c# array initialized with 2 other arrays

Two dimensional C# Array initialized with 2 other arrays

Anonymous User 2509 14-Aug-2014

I'm a bit new to C# and I don't understand how to make this work:

private static readonly Unit[,] UNIT_TYPES = new Unit[,]{LENGTH_UNITS, ANGLE_UNITS};

private static readonly Unit[] LENGTH_UNITS = new Unit[3]{Unit.Millimeters, Unit.Inches, Unit.Centimeters};

private static readonly Unit[] ANGLE_UNITS = new Unit[2]{Unit.Degrees, Unit.Radians};

I'm getting the error "A nested array initializer was expected" on the UNIT_TYPES variable. It seems to not except the fact that LENGTH_UNITS and ANGLE_UNITS will be ready at compile time. What's the best way to rewrite this?

Thanks!


c# c# 
Updated on 14-Aug-2014

I am a content writter !

Can you answer this question?

Answer

1 Answers

Liked By