title: .NET Marshal.PtrToStringUni(IntPtr) vs. new String(char*)
body: <p>What's the difference between <a href="http://msdn.microsoft.com/en-us/library/6y4za026.aspx" rel="nofollow noreferrer"><code>new String(char*)</code></a> and <a href="http://msdn.microsoft.com/en-us/library/dyf0tzy4.aspx" rel="nofollow noreferrer"><code>Marshal.PtrToStringUni(IntPtr)</code></a>, aside from the obvious fact that one takes <code>char*</code> and one takes <code>IntPtr</code>? When should I use which?</p>
  <p>I remember getting a <em>really</em> random access violation that took an enormous amount of time to track down about a couple of years ago when using the constructor, and it went away when I used the <code>PtrToStringUni</code>. Maybe that wasn't the real cause, I don't know, but it seemed to be.</p>
  <p>I never figured out what the difference was, though. Any ideas?</p>
  <hr />
  <h2>Edit:</h2>
  <p><a href="https://stackoverflow.com/questions/2213871/marshal-ptrtostringuni-vs-new-string">This question</a> has the answer to most of my question; however: is there any explanation for my access violation, or was it because of something else?</p>