Reputation: 7923
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.
Upvotes: 2
Views: 4645
Reputation: 39023
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*
{
// ...
}
Upvotes: 6
Reputation: 41
fixed(char* origionalPhrase = phrase)
{
fixed(char* buffer = new char[25])
{
....
....
now you can use origionalphrase and buffer inside.
}
}
Upvotes: 4