title: How to use unichar array in C# struct with DLLImport of unmanaged C
body: <p>I am trying to build a struct in C# to pass to unmanaged C++, I was wondering what is the correct type of variable to use for a <code>unichar</code> array in my struct and what it should be marshalled as.</p>
  
  <p>I have already figured this out for an <code>unsigned char array</code></p>
  
  <p>C/C++</p>
  
  <pre><code>typedef struct _foo {
      void *fileId;
      unsigned char   fileName[15];
  } foo;
  </code></pre>
  
  <p>C#</p>
  
  <pre><code>[StructLayout(LayoutKind.Sequential)]
  public struct foo
  {
     public IntPtr fileId;
     [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 15)]
     public string fileName;
  }
  </code></pre>
  
  <p>So if I have the following in C++</p>
  
  <pre><code>typedef struct _foo {
      void *fileId;
      unichar fileName[15];   //  UTF-16LE
  } foo;
  </code></pre>
  
  <p>What would be the correct struct to use in C#?</p>