Groups | Blog | Home
all groups > dotnet sdk > march 2004 >

dotnet sdk : VARIANT array


Arr S
3/23/2004 3:11:19 AM

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
Andreas Håkansson
3/23/2004 12:29:33 PM
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" <anonymous@discussions.microsoft.com> skrev i meddelandet
news:AE4A7F3B-46CF-4199-BED1-99D3C2CE6342@microsoft.com...
[quoted text, click to view]
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?
[quoted text, click to view]

Arr S
3/23/2004 10:11:09 PM
I am developing a DLL that will be used by applications. These applications pass the data as VARIANT array. In this case, I'll not be knowing the data type of the object sent. Only VARIANT array can help my problem,I suppose. Is their any other way

Thanks Andreas
AddThis Social Bookmark Button