473,385 Members | 1,890 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,385 software developers and data experts.

Passing Generic Object from C# to managed C++

1
I would like to pass a list of String objects from C# to managed C++ as shown below:



// C# code
Expand|Select|Wrap|Line Numbers
  1. using System;
  2.  
  3. using System.Collections.Generic;
  4.  
  5. using System.Text;
  6.  
  7. using APIWrapper;
  8.  
  9. namespace testapp
  10.  
  11. {
  12.  
  13.    class Program
  14.  
  15.    {
  16.  
  17.        static void Main(string[] args)
  18.  
  19.        {
  20.  
  21.             List<String> lSeedIPs;
  22.  
  23.             lSeedIPs.Add("IP1");
  24.  
  25.             lSeedIPs.Add("IP2");
  26.  
  27.             lSeedIPs.Add("IP3");
  28.  
  29.             lSeedIPs.Add("IP4");
  30.  
  31.             SNMPImpl SNMPcImplObj = new SNMPImpl();
  32.  
  33.             SNMPImplObj.test(ref lSeedIPs);
  34.  
  35.        }
  36.  
  37.    }
  38.  
  39. }
  40.  
  41.  
//Managed C++ code
Expand|Select|Wrap|Line Numbers
  1. namespace APIWrapper
  2.  
  3. {
  4.  
  5.      public ref class SNMPImpl
  6.  
  7.      {
  8.  
  9.      public:
  10.  
  11.          void test(List<String^>% lString) {
  12.  
  13.          for(int index = 0;index<lString.Count;index++)
  14.  
  15.          {
  16.  
  17.             Console::Writeline("{0}", lString[index]);
  18.  
  19.          }
  20.  
  21.      }
  22.  
  23. };
  24.  
  25.  
  26.  
When I compile, I get the following error:



"No overload for method 'test' takes '1' arguments"



Similar code compiles for a single String object. Is there a way to pass List objects from C# to managed C++?
Jun 13 '07 #1
0 1010

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Andy | last post by:
Hi Could someone clarify for me the method parameter passing concept? As I understand it, if you pass a variable without the "ref" syntax then it gets passed as a copy. If you pass a...
1
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to...
2
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to...
8
by: JAL | last post by:
Here is my first attempt at a deterministic collection using Generics, apologies for C#. I will try to convert to C++/cli. using System; using System.Collections.Generic; using System.Text; ...
7
by: Tim | last post by:
When there is a need to pass some dynamic information between 2 managed assemblies, the "Dictionary object" in Generic form can be used as a method parameter to pass the information. The...
12
by: abintom | last post by:
hi, i am writing a dll in MC++ for using from C#. For the dll function say 'TestFunc', i need to get a SortedList<string,stringas an argument. I am not very clear about using SortedList in...
17
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
5
by: Kenneth Porter | last post by:
How do I pass a container from C# to C++? My client is writing an app in C# that needs to pass a collection of 3- space vectors to my native C++ library. It will also need to read back the...
2
by: Andrus | last post by:
Winforms UI assembly has static FormManager.FormCreator method which creates forms taking entity as parameter. I need to pass this method to business objects in business assembly so that business...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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...

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.