I am trying this code but it doesn't work. What i am trying to do is basicaly trying to receive a string from the dll and desplay it in a textbox:

C part:
Code:
   __declspec(dllexport) void  GetStringFromDLL()
{
char string[5];
strcpy(string,"un");

return string;
}
C# part:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace dll_import
{
    public partial class Form1 : Form
   {

        [DllImport("dll.dll", CharSet = CharSet.Unicode)]
        public static extern void GetStringFromDLL([MarshalAs(UnmanagedType.LPWStr)] out String str);
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            

        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string m;
           GetStringFromDLL(out m);
           textBox3.Text = m;

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }

}