Sunday, July 26, 2009

[#C] How do I get an int array to allow / use nullable ints?

In #C, how do I get an int array to allow / use nullable ints?





int? numberOfValues = null;





int[] anArray = new int[numberOfValues];





I recieve an error:


Cannot implicitly convert type 'int?' to 'int'. An explicit conversion exists (are you missing a cast?)

[#C] How do I get an int array to allow / use nullable ints?
well you need use the explicit conversion see the code





int? numberOfValues = null;


int[] anArray = new int[System.Convert.ToInt32(numberOfValue...

local florist

No comments:

Post a Comment