How do I get a changed value back from C#

  • Thread starter Thread starter tony
  • Start date Start date
T

tony

Hello!

Assume I have an C++.net function called loadPostNames see below.
loadPostNames( dialog->GetAllPostNames(index) );
This function loadPostNames have GetAllPostNames(index) as a parameter.
Function GetAllPostNames is a method in C#.

Now to my question this identifier index passed as a parameter to method
GetAllPostNames is changed in
C# I want to be able to get the new changed value back to the C++.Net
function..

I have tried several possibilitys but I get compile error.

How should I write?

//Tony
 
Assume I have an C++.net function called loadPostNames see below.
loadPostNames( dialog->GetAllPostNames(index) );
This function loadPostNames have GetAllPostNames(index) as a parameter.
Function GetAllPostNames is a method in C#.

Now to my question this identifier index passed as a parameter to method
GetAllPostNames is changed in
C# I want to be able to get the new changed value back to the C++.Net
function..

I have tried several possibilitys but I get compile error.

How should I write?

You C# method that takes the int should use the ref keyword.
Method(ref int i);

Your C++ call does not have to change if you are using C++/CLI.
See here for an example:
http://www.winterdom.com/cppclifaq/archives/000421.html

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
Hello!!


I don't use C++/CLI I useVS2003 which is managed code.
This GetAllPostNames is an interface so I declared this GetAllPostNames in
this way
System::Collections::ArrayList* GetAllPostNames(ref int index);
and the C# method in this way public ArrayList GetAllPostNames(ref int
stdSopIndex)
This cause a compile error saying syntax error identifier ref.

If I instead declare the interface GetAllPostNames in this way
System::Collections::ArrayList* GetAllPostNames(int index);
and keep and the C# method in this way public ArrayList GetAllPostNames(ref
int stdSopIndex)
I get this compile error.
C:\PK\Development\Products\UTCAS\4.0\SRC\MeltPracApplication\Dialog\ActionFo
rm.cs(16): 'MeltPracAppl.ActionForm' does not implement interface member
'MeltPracCommon.IMeltPracDialog.GetAllPostNames(int)'



What is it that I don't do right?

Can you give me any hint about what I can do to make it work.

//Tony
 
I don't use C++/CLI I useVS2003 which is managed code.
This GetAllPostNames is an interface so I declared this GetAllPostNames in
this way
System::Collections::ArrayList* GetAllPostNames(ref int index);
and the C# method in this way public ArrayList GetAllPostNames(ref int
stdSopIndex)
This cause a compile error saying syntax error identifier ref.

The C# code is ok. leave it like that.
The C++ code is wrong. there is no ref keyword in MC++
I have not used MC++ very much, but I think you need to do this:
GetAllPostNames(int & index);


Btw why did you need to declare the interface in C++?
if it is defined in the C# class lib, there should be no need to declare it
somewhere else I think.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
I don't use C++/CLI I useVS2003 which is managed code.
This GetAllPostNames is an interface so I declared this GetAllPostNames in
this way
System::Collections::ArrayList* GetAllPostNames(ref int index);
and the C# method in this way public ArrayList GetAllPostNames(ref int
stdSopIndex)
This cause a compile error saying syntax error identifier ref.

The C# code is ok. leave it like that.
The C++ code is wrong. there is no ref keyword in MC++
I have not used MC++ very much, but I think you need to do this:
GetAllPostNames(int & index);


Btw why did you need to declare the interface in C++?
if it is defined in the C# class lib, there should be no need to declare it
somewhere else I think.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
Back
Top