{"id":1787,"date":"2016-10-17T17:20:00","date_gmt":"2016-10-17T15:20:00","guid":{"rendered":"http:\/\/blog.rabahi.net\/?page_id=1787"},"modified":"2016-10-17T17:23:07","modified_gmt":"2016-10-17T15:23:07","slug":"cs-call-unmanaged-c-code","status":"publish","type":"page","link":"https:\/\/blog.rabahi.net\/?page_id=1787","title":{"rendered":"cs call unmanaged c\/c++ code"},"content":{"rendered":"<h1>C\/C++ code<\/h1>\n<p>Let&#8217;s create Test.dll library :<\/p>\n<pre lang=\"cpp\">\r\n\/\/ Compile with: \/LD\r\nint __declspec(dllexport) sum(int a,int b) {\r\n  return a+b;\r\n}\r\n<\/pre>\n<h1>C# code<\/h1>\n<h2>Import library<\/h2>\n<pre lang=\"csharp\">\r\n [DllImport(\"Test.dll\"]\r\n  public static extern int sum(int a,int b);\r\n<\/pre>\n<p>Now you can use it like this<\/p>\n<pre lang=\"csharp\">\r\nint result = sum(3,4);\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>C\/C++ code Let&#8217;s create Test.dll library : \/\/ Compile with: \/LD int __declspec(dllexport) sum(int a,int b) { return a+b; } C# code Import library [DllImport(&#8220;Test.dll&#8221;] public static extern int sum(int a,int b); Now you can use it like this int result = sum(3,4);<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1767,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1787","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1787","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1787"}],"version-history":[{"count":5,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1787\/revisions"}],"predecessor-version":[{"id":1792,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1787\/revisions\/1792"}],"up":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1767"}],"wp:attachment":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}