Bernie,
Huh?
Dim arraylistints As New ArrayList
Dim arrayliststrings As New ArrayList
arraylistints.Add(26)
arrayliststrings = arraylistints.Clone
'**** above line works fine
The above line FAILS as arraylistints.Clone returns an Object, you cannot
assign an Object to an Arraylist with Option Strict On with out using
DirectCast! I normally put Option Strict On at the top of each file, so I
know it is really on!
This line WILL work with Option Strict On!
arrayliststrings = DirectCast(arraylistints.Clone, ArrayList)
'**** above line works fine
MessageBox.Show(arrayliststrings(i))
The above line FAILS as arrayliststrings(i) returns an Object,
MessageBox.Show expects a String,
If arrayliststrings contained Strings as Howie wanted, he could use
DirectCast, unfortunately it does not as you used Clone above, which copies
the boxed integers to boxed integers. Using CType will work as CType is
converting the boxed integer to a String. Howie did not want to have to call
CType explicitly.
Note DirectCast will cast an object, to the type it really is, while CType
will attempt to convert the object to the type you are asking.
Unfortunately I do not see a way that Howie can "have his cake & eat it to",
Other then Howie's loop I know of no built-in ways of converting an array of
one type to an array of another type! I'm not sure if one could use
System.Convert.ChangeType in a generalized routine to convert an array of
one type to an array of another type.
Hope this helps
Jay