By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,219 Members | 2,361 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,219 IT Pros & Developers. It's quick & easy.

Late Binding

P: n/a
hi All,

I've decided to use Options Strict ON in one of my apps and now I'm trying
to fix a late binding issue. I have 5 integer arrays:

dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as integer

The integers in these arrays are actually pointers to different columns of
data in a text file.

I create an array of these arrays:

Dim HIndex() as Array = {IA1, IA2, IA3, IA4, IA5}

Then I use two loops to retrieve the integers from the aray of arrays:

Dim xHeader() as String
Dim T_xHeader as ArrayList

For s = 0 to 4
Do some stuff
For i = 0 to HIndex(s).Length -1
Do some stuff
T_xHeader.Add(xHeader(HIndex(s)(i))) 'Late Binding Here
Next i
Do some stuff
Next s

So, HIndex(s)(i) actually points to an value in xHeader, which is then added
to T_xHeader.

This all works fine, but, becasue I'm dimensioning HIndex as an array, I'm
getting a late binding error.

I can't figure out how to dimension HIndex to something other than array, in
order to avoid the late binding.

Any ideas would be greatly appreciated!!

TIA
Lee
Nov 21 '05 #1
Share this Question
Share on Google+
30 Replies


P: n/a
Lee,

Can you have a look at this older however simple sample from me in this
message

http://groups-beta.google.com/group/...e0848bf3?hl=en

When this is not enough, feel free to reply

I hope this helps,

Cor
Nov 21 '05 #2

P: n/a
Hi All,

I'm playing with some ideas regarding my first post.

The first thing I'm trying to do is get rid of the Array of Arrays (as it's
not CLS compliant). So, I'm adding a string array with the names of the
integer arrays:

Dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as integer
Dim Sname as String() = {"IA1", "IA2", "IA3", "IA4", "IA5"}

Dim xHeader() as String
Dim T_xHeader as ArrayList

For s = 0 to Sname.Length - 1
Do some stuff
For i = 0 to CType(Sname(s).Clone, Array).Length - 1
Do some stuff
T_xHeader.Add(xHeader(Sname(s).Clone(i))) 'Late Binding Here
Next i
Do some stuff
Next s

So, I've managed to get rid of the array of arrays, but I still have the
late binding issue.

What I'm tring to avoid is this:

For s = 0 to Sname.Length - 1
Do some stuff
if Sname(s) = "IA1" Then
For i = 0 to IA1.Length - 1
Do some stuff
T_xHeader.Add(xHeader(IA1(i))) 'Early Binding
Next i
Elseif Sname(s) = "IA2" then
For i = 0 to IA2.Length - 1
Do some stuff
T_xHeader.Add(xHeader(IA2(i))) 'Early Binding
Next i
Elseif Sname(s) = "IA3" then
For i = 0 to IA3.Length - 1
Do some stuff
T_xHeader.Add(xHeader(IA3(i))) 'Early Binding
Next i
Elseif Sname(s) = "IA4" then
For i = 0 to IA4.Length - 1
Do some stuff
T_xHeader.Add(xHeader(IA4(i))) 'Early Binding
Next i
Elseif Sname(s) = "IA5" then
For i = 0 to IA5.Length - 1
Do some stuff
T_xHeader.Add(xHeader(IA5(i))) 'Early Binding
Next i
Endif
Do some stuff
Next s

the reason I'm trying to avoid this is to prevent lots of necessary code
changes if the number of Integer arrays changes. Using my first (late
binding) method, the only changes would be to dimension another Integer
array and add it's name to the string array.

TIA
Lee
"lgbjr" <lg***@online.nospam> wrote in message
news:OJ**************@TK2MSFTNGP10.phx.gbl...
hi All,

I've decided to use Options Strict ON in one of my apps and now I'm trying
to fix a late binding issue. I have 5 integer arrays:

dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as integer

The integers in these arrays are actually pointers to different columns of
data in a text file.

I create an array of these arrays:

Dim HIndex() as Array = {IA1, IA2, IA3, IA4, IA5}

Then I use two loops to retrieve the integers from the aray of arrays:

Dim xHeader() as String
Dim T_xHeader as ArrayList

For s = 0 to 4
Do some stuff
For i = 0 to HIndex(s).Length -1
Do some stuff
T_xHeader.Add(xHeader(HIndex(s)(i))) 'Late Binding Here
Next i
Do some stuff
Next s

So, HIndex(s)(i) actually points to an value in xHeader, which is then
added to T_xHeader.

This all works fine, but, becasue I'm dimensioning HIndex as an array, I'm
getting a late binding error.

I can't figure out how to dimension HIndex to something other than array,
in order to avoid the late binding.

Any ideas would be greatly appreciated!!

TIA
Lee

Nov 21 '05 #3

P: n/a
Lee,

See my earlier message, know that IList is the interface that almost every
standard array and collection implements except the VB collection.

And therefore can be used.

Cor
Nov 21 '05 #4

P: n/a
Thanks Cor, I'll see what I can do with this info.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Lee,

See my earlier message, know that IList is the interface that almost every
standard array and collection implements except the VB collection.

And therefore can be used.

Cor

Nov 21 '05 #5

P: n/a
"lgbjr" <lg***@online.nospam> schrieb:
I've decided to use Options Strict ON in one of my apps and now I'm trying
to fix a late binding issue. I have 5 integer arrays:

dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as integer

The integers in these arrays are actually pointers to different columns of
data in a text file.

I create an array of these arrays:

Dim HIndex() as Array = {IA1, IA2, IA3, IA4, IA5}

Then I use two loops to retrieve the integers from the aray of arrays:

Dim xHeader() as String
Dim T_xHeader as ArrayList

For s = 0 to 4
Do some stuff
For i = 0 to HIndex(s).Length -1
Do some stuff
T_xHeader.Add(xHeader(HIndex(s)(i))) 'Late Binding Here


The best solution is to create a jagged array (an array of arrays):

\\\
Dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) As Integer
Dim HIndex()() As Integer = {IA1, IA2, IA3, IA4, IA5}
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #6

P: n/a
Herfried,

The best solution is to create a jagged array (an array of arrays):

\\\
Dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) As Integer
Dim HIndex()() As Integer = {IA1, IA2, IA3, IA4, IA5}
///

You know my question when there is written "the best" without any
explanation.

The way you write it means under all conditions and without any execption.

You know him, however when there is the slightest doubt

Why?

Cor
Nov 21 '05 #7

P: n/a
Cor,
The OP stated he wanted an "array of these arrays".
| I create an array of these arrays:
| Dim HIndex() as Array = {IA1, IA2, IA3, IA4, IA5}

A Jagged or Ragged array is an "array of arrays".
http://msdn.microsoft.com/library/de...ringArrays.asp

Ergo the OP wants a Jagged array as Herfried shows.

Dim HIndex() as Integer() = {IA1, IA2, IA3, IA4, IA5}

or

Dim HIndex()() as Integer = {IA1, IA2, IA3, IA4, IA5}
Hope this helps
Jay
"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
| Herfried,
| >
| > The best solution is to create a jagged array (an array of arrays):
| >
| > \\\
| > Dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) As Integer
| > Dim HIndex()() As Integer = {IA1, IA2, IA3, IA4, IA5}
| > ///
| >
| You know my question when there is written "the best" without any
| explanation.
|
| The way you write it means under all conditions and without any execption.
|
| You know him, however when there is the slightest doubt
|
| Why?
|
| Cor
|
|
Nov 21 '05 #8

P: n/a
Jay,
The OP stated he wanted an "array of these arrays".
| I create an array of these arrays:
| Dim HIndex() as Array = {IA1, IA2, IA3, IA4, IA5}
I know, however he showed his code that looked like this.
Then I use two loops to retrieve the integers from the aray of arrays:
Dim xHeader() as String
Dim T_xHeader as ArrayList


I won't say that the answer from Hefried can not be right, however in my
opinion is it the situation you use it where that is. You will always see
this question from me, when somebody says it is the *best* while he is not
saying why, or in what situation. (Who ever it is).

You would know that I always tell in a completly static situation to use the
way Herfried describes and in a dynamic situation at least not to use a
static array in the dynamic part.

Cor
Nov 21 '05 #9

P: n/a
Cor,
| >Dim T_xHeader as ArrayList
Is part of his output, not part of his input. Hence I don't see it as part
of his question.

By output I mean it is where he is placing the results of his jagged array.
By input I mean the jagged array itself. His output could have just as
easily been a file or another fixed array!

As I stated, he states he wants an array of arrays, which is what Herfried &
I showed.

Hope this help
Jay

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
| Jay,
|
| >The OP stated he wanted an "array of these arrays".
| >| I create an array of these arrays:
| >| Dim HIndex() as Array = {IA1, IA2, IA3, IA4, IA5}
|
| I know, however he showed his code that looked like this.
|
| >Then I use two loops to retrieve the integers from the aray of arrays:
| >Dim xHeader() as String
| >Dim T_xHeader as ArrayList
|
| I won't say that the answer from Hefried can not be right, however in my
| opinion is it the situation you use it where that is. You will always see
| this question from me, when somebody says it is the *best* while he is not
| saying why, or in what situation. (Who ever it is).
|
| You would know that I always tell in a completly static situation to use
the
| way Herfried describes and in a dynamic situation at least not to use a
| static array in the dynamic part.
|
| Cor
|
|
Nov 21 '05 #10

P: n/a
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
Nov 21 '05 #11

P: n/a
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

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uN****************@tk2msftngp13.phx.gbl...
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

Nov 21 '05 #12

P: n/a
teach how to fish
Nov 21 '05 #13

P: n/a
Cor,

"Cor Ligthert" <no************@planet.nl> schrieb:
The question is in my opinion a late binding question (see the subject)
not an array question.
The question is about

| [...] now I'm trying to fix a late binding issue
| [...]
| This all works fine, but, becasue I'm dimensioning HIndex as an array,
| I'm getting a late binding error.
|
| I can't figure out how to dimension HIndex to something other than
| array, in order to avoid the late binding.

All I did was answering this 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.
I don't think that anybody here would say that. We are talking about the
concrete question posted by the OP which was about how to fix a certain
late-binding problem.
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


Nobody except you is talking about something else than "this problem".
When it is possible, than I think that it is *better* to learn how to fish
than to give a fish.


I don't see how 'IList' fits into "how to learn to fish", moreover I think
it's misleading because it's not appropriate for the OP's problem.

Just my 2 Euro cents again...

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #14

P: n/a
"lgbjr" <lg***@online.nospam> schrieb:
But, As I posted earlier, I want to stay away from the jagged array, as
it's not CLS compliant.


CLS-compliance is important for "interfaces" only, which means that a class
library's public methods, for example, should not return jagged arrays.
However, there is no problem with using jagged arrays in an internal
implementation.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #15

P: n/a
Herfried,
moreover I think it's misleading because it's not appropriate for the OP's
problem.


Have a look at the message from the OP, (Lee), that was sent before your
message.

I hope that this previous message from you gives a wrong impression about
you.

Cor
Nov 21 '05 #16

P: n/a
"Cor Ligthert" <no************@planet.nl> schrieb:
Have a look at the message from the OP, (Lee), that was sent before your
message.

I hope that this previous message from you gives a wrong impression about
you.


Huh?! I read the OP's message...

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #17

P: n/a
Cor & lgbjr,
| The question is in my opinion a late binding question (see the subject)
not
| an array question.
As you may know you use Option Strict On to avoid late binding! Simple,
isn't it.

From there you get into specific examples of late binding, such as this
Jagged Array, which again Herfried & I answered how to avoid late binding in
this specific situation

I hope you will agree that there is no single simple answer on how to avoid
Late Binding, other then to turn Option Strict On & handle each of the Late
Binding errors in turn...

Hope this helps
Jay
"Cor Ligthert" <no************@planet.nl> wrote in message
news:uN****************@tk2msftngp13.phx.gbl...
| 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
|
|
Nov 21 '05 #18

P: n/a
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
"lgbjr" <lg***@online.nospam> wrote in message
news:el**************@TK2MSFTNGP12.phx.gbl...
| 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
|
| "Cor Ligthert" <no************@planet.nl> wrote in message
| news:uN****************@tk2msftngp13.phx.gbl...
| > 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
| >
|
|
Nov 21 '05 #19

P: n/a
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

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Ot*************@TK2MSFTNGP12.phx.gbl...
| 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
|
|
| "lgbjr" <lg***@online.nospam> wrote in message
| news:el**************@TK2MSFTNGP12.phx.gbl...
|| 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
||
|| "Cor Ligthert" <no************@planet.nl> wrote in message
|| news:uN****************@tk2msftngp13.phx.gbl...
|| > 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
|| >
||
||
|
|
Nov 21 '05 #20

P: n/a
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
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ew**************@TK2MSFTNGP14.phx.gbl...
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

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Ot*************@TK2MSFTNGP12.phx.gbl...
| 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
|
|
| "lgbjr" <lg***@online.nospam> wrote in message
| news:el**************@TK2MSFTNGP12.phx.gbl...
|| 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
||
|| "Cor Ligthert" <no************@planet.nl> wrote in message
|| news:uN****************@tk2msftngp13.phx.gbl...
|| > 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
|| >
||
||
|
|

Nov 21 '05 #21

P: n/a
Jay,
As you may know you use Option Strict On to avoid late binding! Simple,
isn't it.

No I did not know this, it's in my opinion a completly wrong statement. I
thought you knew better. It can in my opinion give a complete wrong idea
about what Option Strict On does.

However, I made my answer for the OP and was only asking with my reply to
Herfried why he wrote that something was the *best* way.

Programming is in my opinion not a religion where you just has to believe
something when somebody write that.

However probably we disagree about that

Cor
Nov 21 '05 #22

P: n/a
Cor,

"Cor Ligthert" <no************@planet.nl> schrieb:
No I did not know this, it's in my opinion a completly wrong statement. I
thought you knew better. It can in my opinion give a complete wrong idea
about what Option Strict On does.

However, I made my answer for the OP and was only asking with my reply to
Herfried why he wrote that something was the *best* way.


It actually is the best way, even if you don't believe it.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #23

P: n/a
Herfried,
No I did not know this, it's in my opinion a completly wrong statement.
I thought you knew better. It can in my opinion give a complete wrong
idea about what Option Strict On does.

However, I made my answer for the OP and was only asking with my reply to
Herfried why he wrote that something was the *best* way.


It actually is the best way, even if you don't believe it.

--

What do you mean that I don't believe? I don't see it in your quoting. What
are you referring too.

However when you want something based on believe, than you better can change
your study direction, go to a seminary. Now is the time for it while the
natural language from the Pope is German.

Cor
Nov 21 '05 #24

P: n/a
Lee,
Although the VB specification states they are not CLS compliant, the CLS
specification seems to state that sometimes they are CLS compliant (as
suggested by the passages I quoted earlier).

| > | According to The Common Language Infrastructure Annotated Standard:
| > | <quote>NOTE: So-called "jagged arrays" are CLS-compliant,

Which is under CLS Rule 16.

I would value the CLI specification over the VB specification...

Hope this helps
Jay
"lgbjr" <lg***@online.nospam> wrote in message
news:ek**************@TK2MSFTNGP12.phx.gbl...
| 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
|
|
| "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
| news:ew**************@TK2MSFTNGP14.phx.gbl...
| > 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
| >
| >
| >
| > "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in
message
| > news:Ot*************@TK2MSFTNGP12.phx.gbl...
| > | 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
| > |
| > |
| > | "lgbjr" <lg***@online.nospam> wrote in message
| > | news:el**************@TK2MSFTNGP12.phx.gbl...
| > || 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
| > ||
| > || "Cor Ligthert" <no************@planet.nl> wrote in message
| > || news:uN****************@tk2msftngp13.phx.gbl...
| > || > 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
| > || >
| > ||
| > ||
| > |
| > |
| >
| >
|
|
Nov 21 '05 #25

P: n/a
Cor,
| > As you may know you use Option Strict On to avoid late binding! Simple,
| > isn't it.
| No I did not know this, it's in my opinion a completly wrong statement. I
| thought you knew better. It can in my opinion give a complete wrong idea
| about what Option Strict On does.
So what do you feel Option Strict On does?

According to:
http://msdn.microsoft.com/library/de...tionstrict.asp

It does two things:
1. Restricts implicit data type conversions to only widening conversions
(first paragraph)
2. Generates an error for late binding (third paragraph under the remarks).

It would seem obvious to me that if Option Strict On generates an error for
late binding, then ergo it is the what you use to avoid late binding, as
your program has a number of errors which prevents it from running, As I
stated fixing these errors will then avoid the late binding!

| Programming is in my opinion not a religion where you just has to believe
| something when somebody write that.
| However probably we disagree about that
That comment doesn't warrant a response!

Hope this helps
Jay

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uN**************@TK2MSFTNGP14.phx.gbl...
| Jay,
|
| > As you may know you use Option Strict On to avoid late binding! Simple,
| > isn't it.
| >
| No I did not know this, it's in my opinion a completly wrong statement. I
| thought you knew better. It can in my opinion give a complete wrong idea
| about what Option Strict On does.
|
| However, I made my answer for the OP and was only asking with my reply to
| Herfried why he wrote that something was the *best* way.
|
| Programming is in my opinion not a religion where you just has to believe
| something when somebody write that.
|
| However probably we disagree about that
|
| Cor
|
|
Nov 21 '05 #26

P: n/a
Jay,
According to:
http://msdn.microsoft.com/library/de...tionstrict.asp
I know that page, I have read it before I gave my previous answer too you.
It would seem obvious to me that if Option Strict On generates an error
for
late binding, then ergo it is the what you use to avoid late binding, as
your program has a number of errors which prevents it from running, As I
stated fixing these errors will then avoid the late binding! (this is not the text from your previous message by the way which is less
impliciet).

It generates an error and when you correct that, than the object, where is
spoken about in this page, can by instance using casting or converting be
early binded. However "Option Strict On" does not avoid late binding, that
is still posible using reflection.

I showed in my first sample in this thread how to fix those errors where you
are now talking about.

From that Herfried wrote explicitly.I don't see how 'IList' fits into "how to learn to fish", moreover I think
it's misleading because it's not appropriate for the OP's problem.

("learn" was corrected by me in "teach" however Herfried quoted this one).

And because you did not amended or corrected this statement, while you are
active in this thread, do I see this as well as a message from you.

Now you are telling that "Option Strict On" needs fixing errors, while you
agreed first that where I showed how to fix those errors, and was talking
even about using for that the type or the interface, it was wrong. Even for
me, while I know what "Option Strict On" does, very confusing.

I hope this helps

Cor
Nov 21 '05 #27

P: n/a
Cor,
Not worth a response...

Jay

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
| Jay,
|
| > According to:
| >
http://msdn.microsoft.com/library/de...tionstrict.asp
|
| I know that page, I have read it before I gave my previous answer too you.
|
| > It would seem obvious to me that if Option Strict On generates an error
| > for
| > late binding, then ergo it is the what you use to avoid late binding, as
| > your program has a number of errors which prevents it from running, As I
| > stated fixing these errors will then avoid the late binding!
| (this is not the text from your previous message by the way which is less
| impliciet).
|
| It generates an error and when you correct that, than the object, where is
| spoken about in this page, can by instance using casting or converting be
| early binded. However "Option Strict On" does not avoid late binding, that
| is still posible using reflection.
|
| I showed in my first sample in this thread how to fix those errors where
you
| are now talking about.
|
| From that Herfried wrote explicitly.
| >I don't see how 'IList' fits into "how to learn to fish", moreover I
think
| >it's misleading because it's not appropriate for the OP's problem.
| ("learn" was corrected by me in "teach" however Herfried quoted this one).
|
| And because you did not amended or corrected this statement, while you are
| active in this thread, do I see this as well as a message from you.
|
| Now you are telling that "Option Strict On" needs fixing errors, while you
| agreed first that where I showed how to fix those errors, and was talking
| even about using for that the type or the interface, it was wrong. Even
for
| me, while I know what "Option Strict On" does, very confusing.
|
| I hope this helps
|
| Cor
|
|
Nov 21 '05 #28

P: n/a
> Cor,
Not worth a response...


I assume that with this answer (because you asked me impliciet in your last
message for an explanation) that you agree with me.

Option Strict does not as you wrote avoid late binding.

Cor
Nov 21 '05 #29

P: n/a
Cor,
You assume wrong! Its just not worth my time to haggle with you.

Jay
"Cor Ligthert" <no************@planet.nl> wrote in message
news:e8**************@tk2msftngp13.phx.gbl...
|> Cor,
| > Not worth a response...
|
| I assume that with this answer (because you asked me impliciet in your
last
| message for an explanation) that you agree with me.
|
| Option Strict does not as you wrote avoid late binding.
|
| Cor
|
|
Nov 21 '05 #30

P: n/a
Hi Cor,

I understand what Jay is saying (and why you have a problem with what he's
saying).

It's basically a "If A causes B And B causes C, Then A causes C" scenario.

A= Setting Options Strict On
B= Errors from use of late binding
C=Writing Code that avoids Late binding (avoidance of Late binding)

If:

Setting Options Strict On causes errors from use of late binding

And:

Errors from use of late binding causes writing code that avoids late binding
(avoidance of late binding)

Then:

Setting Options Strict On causes avoidance of late binding (or as Jay
stated, Use Options Strict On to avoid late binding)

While the assumption that A causes C is correct in this scenario, it is not
always true:

If People eat cows and cows eat grass, then people eat grass. :-)

Cheers
Lee

"Cor Ligthert" <no************@planet.nl> wrote in message
news:e8**************@tk2msftngp13.phx.gbl...
Cor,
Not worth a response...


I assume that with this answer (because you asked me impliciet in your
last message for an explanation) that you agree with me.

Option Strict does not as you wrote avoid late binding.

Cor

Nov 21 '05 #31

This discussion thread is closed

Replies have been disabled for this discussion.