Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In c++ there is the <code>delete</code> keyword to delete anything you want from memory. Of course you can with it delete arrays as well, so you can write a function in c++ that takes an array as parameter, and in the implementation you just add one line of code that deletes it immediately. If this function belongs to a class in a class library project, then you can add the reference in C#, create the instance using the namespace and call the function, or not creating the instance, if the function was declared static. </p> <p>If the project type in c++ was not class library, but just a dll file, then you should export the declared function (extern "C" __declspec( dllexport ) and in c# use it using <code>System.Runtime.InteropServices.DllImport</code>. When you use dll import, it is important that you specify the dll file path string, and after add calling <code>Convention = CallingConvention</code>. Cdecl, if you don't want to get exceptions and problems every time you call the imported function. </p> <p>You can read in the internet how to do all this. Hope this is a good idea.</p> <p>Code example:</p> <p>C++ dll project:</p> <pre><code>extern "C" __declspec( dllexport ) void Delete(array&lt;__int32&gt;^ arr) { delete arr; } </code></pre> <p>C# project:</p> <pre><code>using System; using System.Runtime.InteropServices; namespace DeleteArray { class Program { [DllImport("...DeleteArray.dll", Convention=CallingConvention)] static extern void Delete(int[] arr); static int Main(string[] args) { int[] array = new int[] { 1, 2, 3, 4, 5 }; foreach (int integer in array) { Console.WriteLine(integer); } Delete(array); Console.Write(array[0]); //Runtime error! return 0; } } </code></pre> <p>}</p> <p>I have tried this at home and it worked excellent for me, so why not to others too!?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload