VARIANT array

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to use a VARIANT array. But, I am not sure whether it's available in C#. I found a VARIANT API in the platform SDK (in the OleAuto.h file). Is this is the right one that I've to use? If so, how to include this .h file

Thanks in advance
Arr S.
 
Arr,

You should use an array of objects. The Object class is the base class
for
everything in .NET, just like Java uses.

object[] myArray = new object[10];

myArray[0] = 1;
myArray[1] = "Something";
myArray[2] = true;

Not that implicit type casting is taking place. That is all of your other
varaibles,
be it an int, string, bool or anything else, will be converted into an
object and if
you need to get it back you will have to perform explicit type casting

int a = (int)myArray[0];
string b = (string)myArray[1];
bool c = (bool)myArray[2];

Hope this helps,

//Andreas

Arr S said:
I need to use a VARIANT array. But, I am not sure whether it's available
in C#. I found a VARIANT API in the platform SDK (in the OleAuto.h file).
Is this is the right one that I've to use? If so, how to include this .h
file?
 
Back
Top