vb.net - Linq statement: Inner function call conflicts with enclosing method name -


cryptic title, start code poses problem , clarify afterwards:

public readonly property max double             dim res = (from double() in values select a.max).max         return res     end end property 

values jagged array of double,

private values()() double 

that initialized elsewhere. want use linq extract overall maximum value. code above gives following exception first .max:

bc30978 range variable 'max' hides variable in enclosing block or range variable defined in query expression.

if change property name else getmaximum error disappears.

why can't call .max function double() variable a selected jagged array? call has in slightest name of method in?

i using visual studio community 2015 on windows 8.1. both answers in vb.net or c# appreciated.

workarounds

as workaround can example following:

private function getmax(a double()) double     return a.max end function public readonly property max double             dim res = (from double() in mvalues select getmax(a)).max         return res     end end property 

no error there, inner .max responsible error.

as mentioned earlier, works:

public readonly property getmax double             dim res = (from double() in values select a.max).max         return res     end end property 

so conflict between first .max , property name.

i can't explain why it's wrong you're doing. i'm suspecting scope of select "max" indeed conflicting property name, indicated. maybe else can jump in explanation.

either way, seems work alternative:

public readonly property max double             return values.max(function(a) a.max)     end end property 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -