473,791 Members | 3,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I define type variant in c#?

How can I define type variant in c#?
Jan 7 '08 #1
4 12152
use datatype object. you can use the is operator to determine type

void mtProc(object obj)
{
if (obj is int)
...
else if (obj is string)
...
else if (obj is myDatatype)
....
}

to call any methods other than the object generic, you will need to use a
cast.

note: if you are call calling a com routine, object is also the type that is
used for a variant parameter (or return value)

-- bruce (sqlwork.com)
"rkbnair" wrote:
How can I define type variant in c#?
Jan 7 '08 #2
Thanks. What should I do if I do not know the return type of a class/function
of a certain thirdparty library?

In VB I can say

variant abcd=MyThirdPar tyLib.MyThirdPa rtyLibFunction( )

What would be the equivalent in C#?

"bruce barker" wrote:
use datatype object. you can use the is operator to determine type

void mtProc(object obj)
{
if (obj is int)
...
else if (obj is string)
...
else if (obj is myDatatype)
....
}

to call any methods other than the object generic, you will need to use a
cast.

note: if you are call calling a com routine, object is also the type that is
used for a variant parameter (or return value)

-- bruce (sqlwork.com)
"rkbnair" wrote:
How can I define type variant in c#?
Jan 7 '08 #3
The .NET Framework does not have a "variant" type. If you start typing the
method signature of a referenced third-party library in the Visual Studio
IDE, Visual Studio Intellisense will show you the return type of the method.

Failing that, you can do this:

Object abcd=MyThirdPar tyLib.MyThirdPa rtyLibFunction( );

type t = typeof(abcd);

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"rkbnair" wrote:
Thanks. What should I do if I do not know the return type of a class/function
of a certain thirdparty library?

In VB I can say

variant abcd=MyThirdPar tyLib.MyThirdPa rtyLibFunction( )

What would be the equivalent in C#?

"bruce barker" wrote:
use datatype object. you can use the is operator to determine type

void mtProc(object obj)
{
if (obj is int)
...
else if (obj is string)
...
else if (obj is myDatatype)
....
}

to call any methods other than the object generic, you will need to use a
cast.

note: if you are call calling a com routine, object is also the type that is
used for a variant parameter (or return value)

-- bruce (sqlwork.com)
"rkbnair" wrote:
How can I define type variant in c#?
Jan 7 '08 #4
That will do it.

Thanks a lot.
"Peter Bromberg [C# MVP]" wrote:
The .NET Framework does not have a "variant" type. If you start typing the
method signature of a referenced third-party library in the Visual Studio
IDE, Visual Studio Intellisense will show you the return type of the method.

Failing that, you can do this:

Object abcd=MyThirdPar tyLib.MyThirdPa rtyLibFunction( );

type t = typeof(abcd);

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"rkbnair" wrote:
Thanks. What should I do if I do not know the return type of a class/function
of a certain thirdparty library?

In VB I can say

variant abcd=MyThirdPar tyLib.MyThirdPa rtyLibFunction( )

What would be the equivalent in C#?

"bruce barker" wrote:
use datatype object. you can use the is operator to determine type
>
void mtProc(object obj)
{
if (obj is int)
...
else if (obj is string)
...
else if (obj is myDatatype)
....
}
>
to call any methods other than the object generic, you will need to use a
cast.
>
note: if you are call calling a com routine, object is also the type that is
used for a variant parameter (or return value)
>
-- bruce (sqlwork.com)
>
>
"rkbnair" wrote:
>
How can I define type variant in c#?
Jan 7 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2779
by: Vilmar Brazão de Oliveira | last post by:
HI, How verify MIME type of file?? Which components should I use? Still now I couldn't find anything! OBS.: I don´t to check file extensions! Thanks,
3
2119
by: Vinodh Kumar P | last post by:
Whenever I read any C++ literature I find the words "C++ is statically type checked".OK.Agreed. Is there any language that supports "Dynamic type checking"? In such a case any type can be assigned to any other type during compile time?
4
4226
by: Claus77 | last post by:
Hi there, I've got a little problem with the following: I'm just writing a com-application in C++ with VS-6, which should also be used with VB-Script, so I have to use variables of type VARIANT in my functions in order to get no problems with VB-Script. I try to transform them into C++-Variables somehow like this:
3
2566
by: G Gerard | last post by:
Hello If Variant type is the data type that contains any kind of data type is there a reason why one would not always use Variant when declaring variables? Thanks G Gerard
1
1508
by: darrenbenn | last post by:
I need to convert this code to VB .NET (2003). Dim FaxMsg As IFaxMessage Set FaxMsg = gFC.NewMessage Dim Recip As Variant ' add a recipient to the fax recipients collection Set Recip = FaxMsg.Recipients.Add(0) Recip.Name = sWho
1
1781
by: G Gerard | last post by:
Hello I am creating a wizard so a user can import data from other type of databases (DBase IV, Paradox etc...) into an Access mdb. The first step would require the user to choose the type and path of database. I would then like to display a list of tables in that database available for import.
3
6115
by: empire5 | last post by:
I'm trying to convert a MS-Sql 6.5 VB application to SQL 2005 and vb.net. The vb app has uses a variant data type. When I try to read the variant data type from the sql 2005 database I get 8,000 characters into the variant type, however when I use the 6.5 database I get only the limited number of characters that are actually in the column.
1
2196
by: Coll | last post by:
I have a function that calculates a period of time e.g. 2.3 years, .5 years etc. I was using the function in a query, but since I had not declared a data type for the function, it wasn't sorting numerically in my query. Can you help me figure out which data type is appropriate for my function. I tried type Long, but that doesn't seem to include decimals. I tried Single, but I can't seem to round it to just one decimal (I tried in the...
1
3242
by: captainc | last post by:
I have C++ code to import a .tlb and use a .dll that has functions that return VARIANT types and accepts BSTRs (bstrings). I have seen that python has modules that can manipulate VARIANTs and BSTRs in the win32com or comtypes.automation packages. I began to use Boost.Python to script some of my code. I tried to send the VARIANT back to python by having the extension module's functions return a VARIANT or VARIANT*; I even tried _variant_t. In...
0
9517
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10156
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5435
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.