473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

com dll object[] to int[]

I have a com dll with following method:

System.Object ComGetLocalBatchNumbers ( System.Int32 pn_errorcode ,
System.Int32 maxBatchNumbers )

I use this code to call the method:
int errCode;
object batchNumbers = kit.ComGetLocalBatchNumbers(out errCode, 1024);

I need to convert object "batchNumbers" to an array of int so I can call
another method:
ComLoadLocalBatch ( System.Int32 pn_errorcode , System.Int32 nBatchNumber )
I have tried to read the type of "batchNumbers" with:
temp.GetType().ToString()
and the type is: System.object[]
How do I iterate over the array of object "batchNumbers" and convert to int?
foreach(object o in batchNumbers) doesn't work

Nov 16 '05 #1
2 1488
Jesper Nilsson wrote:
I have a com dll with following method:

System.Object ComGetLocalBatchNumbers ( System.Int32 pn_errorcode ,
System.Int32 maxBatchNumbers )

I use this code to call the method:
int errCode;
object batchNumbers = kit.ComGetLocalBatchNumbers(out errCode, 1024);

I need to convert object "batchNumbers" to an array of int so I can call
another method:
ComLoadLocalBatch ( System.Int32 pn_errorcode , System.Int32 nBatchNumber )
I have tried to read the type of "batchNumbers" with:
temp.GetType().ToString()
and the type is: System.object[]
How do I iterate over the array of object "batchNumbers" and convert to int?
foreach(object o in batchNumbers) doesn't work


Since ComGetLocalBatchNumbers appears to return an object[],
just cast to one:

object[] batchNumbers = (object[])
kit.ComGetLocalBatchNumbers(out errCode, 1024);

foreach(object o in batchNumbers) ...

bye
Rob
Nov 16 '05 #2
Thank you very much for your answer. It works perfect

/Jesper

"Robert Jordan" wrote:
Jesper Nilsson wrote:
I have a com dll with following method:

System.Object ComGetLocalBatchNumbers ( System.Int32 pn_errorcode ,
System.Int32 maxBatchNumbers )

I use this code to call the method:
int errCode;
object batchNumbers = kit.ComGetLocalBatchNumbers(out errCode, 1024);

I need to convert object "batchNumbers" to an array of int so I can call
another method:
ComLoadLocalBatch ( System.Int32 pn_errorcode , System.Int32 nBatchNumber )
I have tried to read the type of "batchNumbers" with:
temp.GetType().ToString()
and the type is: System.object[]
How do I iterate over the array of object "batchNumbers" and convert to int?
foreach(object o in batchNumbers) doesn't work


Since ComGetLocalBatchNumbers appears to return an object[],
just cast to one:

object[] batchNumbers = (object[])
kit.ComGetLocalBatchNumbers(out errCode, 1024);

foreach(object o in batchNumbers) ...

bye
Rob

Nov 16 '05 #3

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

Similar topics

1
by: Bo Xu | last post by:
Object of Combination By Bo Xu Introduction A combination of n things, taken s at a time, often referred as an s-combination out of n, is a way to select a subset of size s from a given set of...
5
by: surrealtrauma | last post by:
the requirement is : Create a class called Rational (rational.h) for performing arithmetic with fractions. Write a program to test your class. Use Integer variables to represent the private data...
100
by: E. Robert Tisdale | last post by:
What is an object? Where did this term come from? Does it have any relation to the objects in "object oriented programming"?
9
by: Andrew Au | last post by:
Dear all, I am trying to write a piece of software that use Object Oriented design and implement it with C, I did the following == In Object.h == typedef struct ObjectStructure* Object; ...
14
by: Matt | last post by:
I want to know if "int" is a primitive type, or an object? For example, the following two approaches yield the same result. > int t1 = int.Parse(TextBox2.Text); //method 1 > int t2 =...
9
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows security to manage the permissions. Why reinvent...
8
by: a | last post by:
I'm trying to save data from a custom object into the profile object, but it is not structured the way that I want. I'm trying to get the custom object to serialize as xml to a Profile object...
0
by: a | last post by:
I need to create an instance of a custom object 'School.Teacher' and use it in a Profile object. I'm developing a bad case of "Pretzel Logic" thinking about this. Filling the custom object ...
13
by: Mike S | last post by:
I came across the following paragraph in the "Semantics" section for simple assignment in N1124 (C99 draft) and I'm wondering if I'm interpreting it right: 6.5.16.1p3: If the value being...
47
by: Thierry Chappuis | last post by:
Hi, I'm interested in techniques used to program in an object-oriented way using the C ANSI language. I'm studying the GObject library and Laurent Deniau's OOPC framework published on his web...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.