I have a method that gets a nested array as parameter:
Number[][] data
where Number is my very simple class that inherits from INotifyPropertyChange.
And then i have a statement like this:
double[] max = (double[])data.Select(crArray => crArray.Select( cr => cr.ValueNorm ).Max());
When I’m trying to watch it in the debugger it just skips it and the whole method though no exception pops out.
What is the answer? And what is the better way to do it.
I can use loops, of course – but it looks so dirty and long. So LINQ is preferrable
P.S. I’m using VS2008 SP1
Are you sure that the Select method returns an array? Casting + generics = code smell
Try this:
Conversion Method – (ToArray) allocates a new array and populates it. Bound by the restrictions of methods.
Down Casting – Allows you to change the type of the reference to an object instance. Only the actual instance type, or some type that the instance type inherits from are allowed. Anything else gives a runtime exception.
Explicit Conversion Operator – uses the syntax of down casting, to achieve the effect of conversion. It’s really a Conversion Method. This is an endless source of confusion for people trying to understand casting.
Consider this code:
Why didn’t you get a runtime exception in vs? I don’t know.