Multiple Pointers in Fixed(){} initialized with "new" does not work
.net, c#, fixed-statement, unsafe
Solution
Well, the MSDN example has only one char * (or actually byte *). Remove the second one.
fixed(char* origionalPhrase = phrase, buffer = new char[25])
// ^-- removed char*
{
// ...
}
Problem
When I try to initialize a new char* array using fixed while being ilitialized allong side other things, it does not work. The following code is an example of that ``` fixed (char* buffer = new char[25]) { //This works just fine }; fixed (char* origionalPhrase = phrase, char* buffer = new char[25]) { //This does not } ``` The syntax parser underlines the new char[25] as being "Cannot implicitly convert type 'char[]' to 'char*'". I need both those variables to be initialized as char* arrays. The first variable, origionalPhrase variable initializes just fine. The MSNDN documentation points out that: ``` fixed (byte* ps = srcarray, pd = dstarray) {...} ``` will work. I used this MSDN article.