Archived

This topic is now archived and is closed to further replies.

Roof Top Pew Wee

Playing with Pointers in C#.

Recommended Posts

So I''m trying out the pointers in C# and I am having some trouble. To simplify what I am trying to do:

public unsafe class MyClass
{
     float* myFloatPtr;

     public setFloat(ref setTo)
     {
         // first I tried this

         // myFloatPtr= &setTo;

         // but then read that I have to have it fixed so I tried

         fixed(myFloatPtr = &setTo);
     }
}
With the fixed part, my error says "Identifier expected" and underlines the = sign. In all of the examples I saw, the fixed was the beginning of some brackets where they use the pointer in the function, and the pointer falls out of scope. How do I make it so that the pointer can be a member of the class? --Vic--

Share this post


Link to post
Share on other sites