"Sankar Nemani" <sn*****@nospamlumedx.com> schrieb:
Why does the following code throw an exception?
Dim o1() As Object = New Object() {"Sankar", "Sankar2"}
s = DirectCast(o1, String())
This won't work. You'll have to cast each item in the array individually.
\\\
Dim o1() As Object = {"Sankar", "Sankar2"}
Dim s1(o1.Length - 1) As String
For i As Integer = 0 To o1.Length - 1
s1(i) = DirectCast(o1(i), String)
Next i
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>