© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
6 replies
Jonathan Wilson

❔ Need help with C#/C++ interop

I have a C++ dll (that I can't change or port to C#) that exports this function
void func(const unsigned char* in, unsigned char* out, int size)
void func(const unsigned char* in, unsigned char* out, int size)

I have some C# code that obtains a size, creates an input byte[] array holding "size" bytes of data and then creates an output byte[] array with new byte[size]. How would I declare my C++ function in C# and how would I then call it (passing in the byte arrays and size so the C++ dll gets what it expects, i.e. a pair of pointers to raw bytes it can read from and write to plus the size of those arrays)
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ need help with c#
C#CC# / help
3y ago
C# and native interop with JNI
C#CC# / help
16mo ago
İ need help with c#
C#CC# / help
2y ago
✅ Need help with debugging C++
C#CC# / help
2y ago