-
-
Save nassor/792644af41dbd27eabeda83a5d139480 to your computer and use it in GitHub Desktop.
Use a library compiled in Go in c# (.net)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
using System.Text; | |
namespace GoSharedDLL | |
{ | |
class Program | |
{ | |
[DllImport("shared.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)] | |
private static extern IntPtr ReturnReversedString(byte[] input); | |
static void Main(string[] args) | |
{ | |
var input = Encoding.UTF8.GetBytes("Hello World!"); | |
var resultbytes = ReturnReversedString(input); | |
var output = Marshal.PtrToStringAnsi(resultbytes); | |
Console.WriteLine(output); | |
Console.WriteLine("Press enter to continue..."); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment