Thinking about my last little quiz, I realize there are thousands (literally) of new methods across the framework in Whidbey.  How better to introduce\explain them than illustrating the problem they are intended to fix..

 

Let’s say you had this code:

        string[] inputValues = {"0","1","2","3","4","5","6","7","8","9","10","bad value"};

        int[] outputValues;

        outputValues = (int[])inputValues;

Clearly that last line will not compile….

foo.cs(11,24): error CS0030: Cannot convert type 'string[]' to 'int[]'

 

But how do you convert all the that string[] to an int[]?  What if you want out of range inputs to map to -1?  See if you can do it with no loops (foreach, while, for, etc), oh, and while you are at it no exception handling either…  And for extra credit, print the odd values out to the console in red ;-).