L
lgbjr
Hi All,
Actually, funny you mentioned the 2.0 Framework. The only reason I even
considered not using a jagged array was based on info I read in VS.NET 2005
docs. I've actually converted a copy of my project to run under 2.0, mostly
to get a feel for the 2005 IDE, but also to see what I might be up against
when clients wanted to go to the 2.0 framework.
To see just how easy it is to work in 2005, this is where I initially turned
Options Strict On, as all of the errors produced come with nice little
recommended fixes. when I got to the late binding issue regarding HIndex, I
started looking at Array of Arrays (just as Herfield and Jay said, using
HIndex()(), rather than HIndex() ). From the 2005 docs:
Jagged arrays are not compliant with the Common Language Specification
(CLS). This means you should not expose jagged arrays from any class you
want CLS-compliant code to consume.
Without really reading the second sentence, I decided I really didn't want
to introduce a potential problem into my app. However, I agree with Jay.
This is a private implementation, so the jagged array stays and it fixes the
late binding, so, that, as they say, is that!
thanks guys!!
Lee
Actually, funny you mentioned the 2.0 Framework. The only reason I even
considered not using a jagged array was based on info I read in VS.NET 2005
docs. I've actually converted a copy of my project to run under 2.0, mostly
to get a feel for the 2005 IDE, but also to see what I might be up against
when clients wanted to go to the 2.0 framework.
To see just how easy it is to work in 2005, this is where I initially turned
Options Strict On, as all of the errors produced come with nice little
recommended fixes. when I got to the late binding issue regarding HIndex, I
started looking at Array of Arrays (just as Herfield and Jay said, using
HIndex()(), rather than HIndex() ). From the 2005 docs:
Jagged arrays are not compliant with the Common Language Specification
(CLS). This means you should not expose jagged arrays from any class you
want CLS-compliant code to consume.
Without really reading the second sentence, I decided I really didn't want
to introduce a potential problem into my app. However, I agree with Jay.
This is a private implementation, so the jagged array stays and it fixes the
late binding, so, that, as they say, is that!
thanks guys!!
Lee
Jay B. Harlow said:Hmm...
| Which I read to mean that the jagged array "Integer()()" is implemented
as
| an "System.Array of System.Array Of Integer", of course if you look at
the
| IL shows this is how they are implemented!
Reading that just now, it doesn't make as much sense as I thought it did
when I wrote it. :-(
Reading the annotation accompanying Rule 16 in the Common Language
Infrastructure Annotated Standard it appears I was partially correct. What
I'm not certain about is if you do not overload a method on Jagged arrays
if
the method is CLS compliant or not. It definitely appears if you overload
a
method based on Jagged Arrays they are definitely not CLS compliant.
For example:
Public Compliant
Public Sub Sum(ByVal values As Integer()())
End Sub
End Class
Public Class NoneCompliant
Public Sub Sum(ByVal values As Integer()())
End Sub
Public Sub Sum(ByVal values As Single()())
End Sub
End Class
The way I am understanding the standard, the NoneCompliant class is not
compliant as both methods are treated as "Sum(ByVal values As
System.Array())", while the Compliant class may be compliant as there is
only a single method (its not overloaded)...
I'll have to see if I can find more info on this. Also I would be curious
if
.NET 2.0 has clarified this any...
Either way, as was suggested, if the jagged array is a private
implementation detail of the type or method (its not Publicly exposed)
then
the entire discussion of it being compliant or not, although interesting,
is
largely academic.
Hope this helps
Jay
| lgbjr,
|| But, As I posted earlier, I want to stay away from the jagged array, as
| it's
|| not CLS compliant.
| Where do you get that impression???
|
| According to The Common Language Infrastructure Annotated Standard:
| <quote>NOTE: So-called "jagged arrays" are CLS-compliant, but when
| overloading multiple array types they are one-dimensional, zero-based
arrays
| of type System.Array.</quote>
|
| Which I read to mean that the jagged array "Integer()()" is implemented
as
| an "System.Array of System.Array Of Integer", of course if you look at
the
| IL shows this is how they are implemented! Its just that C# & VB.NET
offers
| syntactical sugar to simplify it to Integer()() or int[][]. As you found
| putting an array, any array into a System.Array variable requires late
| binding, if you put the array into a strongly typed variable, such as
| Integer()(), then you avoid the late binding. Also using strongly typed
| variables may enable the compiler to use array specific IL instructions
| instead of the methods on System.Array...
|
| Hope this helps
| Jay
|
|
| || Hi All,
||
|| Cor, you are correct, the issue was really related to late binding,
though
| I
|| understand why Jay and Herfield hit on the jagged array.
||
|| But, As I posted earlier, I want to stay away from the jagged array, as
| it's
|| not CLS compliant.
||
|| I had to move onto something else temporarily, but I'll post back
tomorrow
|| with any questions regarding Cor's possible solution!
||
|| Thanks
||
|| Lee
||
|| || > Jay,
|| >
|| > The question is in my opinion a late binding question (see the
subject)
|| > not an array question.
|| >
|| > When you say like Herfried that, using a jagged array is always the
best
|| > solution to overcome late bindings problems, than I have nothing more
to
|| > discus.
|| >
|| >> The best solution is to create a jagged array (an array of arrays):
|| >
|| > That maybe the jagged array is the best solution for this problem,
can
| be.
|| > However, does not for me answer his more implicit question how to
| overcome
|| > late binding in general. I nowhere saw that in yours and either in
|| > Herfrieds text.
|| >
|| > When it is possible, than I think that it is *better* to learn how to
| fish
|| > than to give a fish.
|| >
|| > I hope this helps
|| >
|| > Cor
|| >
||
||
|
|