Topaz Filer - Email filing software
VB Variant Equivalent in C#
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vb.


Marcus Kellermann
GOOD ANSWER
I have a COM object in which one of the methods returns an ARRAY of type
VARIANT. (Basically an array of strings). From what I have found VARIANT
is SYSTEM.OBJECT in C#. But I don't understand how to use it? Any
idea/references Haven't really found anything in .NET help files..

-Marcus Kellerman

Reply to this message...
Vote that this is a GOOD answer... (2 votes from other users already)
 
 
    
Richard Childress
GOOD ANSWER
"Marcus Kellermann" <Click here to reveal e-mail address> wrote in message
news:eQ1sWGJSBHA.1476@tkmsftngp04...
[Original message clipped]

A Variant is not necessarily the same thing as System.Object.

A Variant is a variable that can contain any type of data. The type of the
data is also stored in the Variant.

If my Variant contains "foo", it contains the string "foo" and also type
information indicating that a string is stored.

The .NET type system is slightly different. All types in the .NET framework
inherit from System.Object. This includes 'primitive' types. (e.g.
Integers), (stack vs. heap allocation is dealt with by something called
boxing and unboxing which I won't get into). Anyway, since all types
inherit from System.Object, any variable can be stored in an Object
variable.
So the two are the same, but not. ;)

You should be able to just declare a variable as a string array :

Dim str() as String

Then capture the return value :

str = objMyObject.MyMethod()

And str should contain your array of strings.

Hope this helps.

Reply to this message...
Vote that this is a GOOD answer... (2 votes from other users already)
 
 
 
System.Object




Ad
BootFX
Reliable and powerful .NET application framework.
Looking to invest in a major software project? Technical and commercial advice available here.
Other Helpful Sites
MBR 247
Topaz Filer
SharePoint Email Filing
Software Advisory Services
 
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734