Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / February 2007

Tip: Looking for answers? Try searching our database.

Simple Question - Passing Arrays to Functions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rich - 25 Feb 2007 14:22 GMT
I need to pass an array from C# to a managed C++ function (that will
in turn call unmanaged C code).  My knowledge of managed C++ syntax is
limited (obviously).  This needs to be a reference parameter so the
function can change the contents of the array and give it back to the
caller.

How should I declare this array parameter in the managed C++ function?
David Anton - 25 Feb 2007 15:10 GMT
By 'managed' do you mean C++/CLI?
If so, then the following example accepts an integer array by ref:
void Foo(array<int> ^%ThisArray)
{
}
But, unless you are changing the array reference, the following will do:
void Foo(array<int> ^ThisArray)
{
}
You do not have to pass by ref if just changing the contents of an array
since the array reference is not changing.
Signature

David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter

> I need to pass an array from C# to a managed C++ function (that will
> in turn call unmanaged C code).  My knowledge of managed C++ syntax is
[quoted text clipped - 3 lines]
>
> How should I declare this array parameter in the managed C++ function?
Rich - 25 Feb 2007 15:45 GMT
On Feb 25, 8:10 am, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
> By 'managed' do you mean C++/CLI?
> If so, then the following example accepts an integer array by ref:
[quoted text clipped - 23 lines]
>
> - Show quoted text -

PERFECT - That is exactly what I needed.  Thanks very much!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.