cast problem

S

Sam

Hi,
I can't figure out which cast I should do (using DirectCast) to solve
this one :

Dim aRow1 As Array
dtData.Rows(nRow2).ItemArray = aRow1

Option Strict On disallows implicit conversions from 'System.Array' to
'1-dimensional array of System.Object'.


Thx
 
N

Nick Hall

Two choices: -

1. Use DirectCast(aRow1, Object())
2. Declare aRow1 directly as an array of objects e.g. Dim aRow1() as Object

Usually, you use the Array class directly only if you need to call one of
the shared methods (e.g. Sort, IndexOf) or if the array type is unknown
until runtime.

Hope this helps,

Nick Hall
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top