__gc* equivalent in VC++ 2005
-
I understand that the equivalent for __gc in VC++ 2005 is ref keyword. Similarly can anyone update me on the equivalent for __gc* in VC++ 2005. Thanks in advance Thanks and Regards Madhu
madhusri wrote:
I understand that the equivalent for __gc in VC++ 2005 is ref keyword. Similarly can anyone update me on the equivalent for __gc* in VC++ 2005. Thanks in advance
I answered this in the MS forum too. But since you've posted here, and since others may have the same question in future, here's the answer once again :-
A^ a = gcnew A();
The A^ is a handle to the managed object A (similar to __gc* in MC++) Regards, NishMy blog : Nish’s thoughts on MFC, C++/CLI and .NET
-
madhusri wrote:
I understand that the equivalent for __gc in VC++ 2005 is ref keyword. Similarly can anyone update me on the equivalent for __gc* in VC++ 2005. Thanks in advance
I answered this in the MS forum too. But since you've posted here, and since others may have the same question in future, here's the answer once again :-
A^ a = gcnew A();
The A^ is a handle to the managed object A (similar to __gc* in MC++) Regards, NishMy blog : Nish’s thoughts on MFC, C++/CLI and .NET
Sivakumar, Thanks for your response. I had actually tried with this option earlier. But then i did not get the problem solved. May be i'll try explaning you what i actually need with this code segment so that you can help me out. The objective is i have to access a dll through C# code. The dll is created from VC++ code. In the C# code i need to pass the address as the function argument. In VS 2003 i could achieve it through the following C++ code segment: public:void GetIntReturn(int __gc* ivalue) { *ivalue=10; } Here's the C# code segment calling the corresponding function. public int GetValueFromC++() { int i =0; GetIntReturn(ref i) return i; } This work fine and this is what i want. But now i got to do the same using VS2005. As you said earlier i tried replacing __gc* with ^. But when invoking this function in C# it asks me for value type and not reference type. Can you help me out with this please. Thanks and Regards Madhu
-
Sivakumar, Thanks for your response. I had actually tried with this option earlier. But then i did not get the problem solved. May be i'll try explaning you what i actually need with this code segment so that you can help me out. The objective is i have to access a dll through C# code. The dll is created from VC++ code. In the C# code i need to pass the address as the function argument. In VS 2003 i could achieve it through the following C++ code segment: public:void GetIntReturn(int __gc* ivalue) { *ivalue=10; } Here's the C# code segment calling the corresponding function. public int GetValueFromC++() { int i =0; GetIntReturn(ref i) return i; } This work fine and this is what i want. But now i got to do the same using VS2005. As you said earlier i tried replacing __gc* with ^. But when invoking this function in C# it asks me for value type and not reference type. Can you help me out with this please. Thanks and Regards Madhu
Ah ok, the C++/CLI equivalent for that is
void GetIntReturn(int% ivalue)
{
ivalue = 10;
}Regards, Nish
My blog : Nish’s thoughts on MFC, C++/CLI and .NET
-
Ah ok, the C++/CLI equivalent for that is
void GetIntReturn(int% ivalue)
{
ivalue = 10;
}Regards, Nish
My blog : Nish’s thoughts on MFC, C++/CLI and .NET
-
Ah ok, the C++/CLI equivalent for that is
void GetIntReturn(int% ivalue)
{
ivalue = 10;
}Regards, Nish
My blog : Nish’s thoughts on MFC, C++/CLI and .NET
-
Thanks we got an idea. but this doesn't work on class ,string and structures how can this be used for those data types Regards Srini
Sriinii wrote:
Thanks we got an idea. but this doesn't work on class ,string and structures
In what way does it not work? Regards, Nish
My blog : Nish’s thoughts on MFC, C++/CLI and .NET
-
Thanks we got an idea. but this doesn't work on class ,string and structures how can this be used for those data types Regards Srini
You have to do the following:
void GetStringReturn(String^% stringValue) { stringValue = "10"; }
-- modified at 14:59 Friday 3rd February, 2006 -
You have to do the following:
void GetStringReturn(String^% stringValue) { stringValue = "10"; }
-- modified at 14:59 Friday 3rd February, 2006