Archived

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

Playing with Pointers in C#.

This topic is 5147 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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 on other sites
Sorry to bump, but does no one know the answer to this?

--Vic--

Share on other sites
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp10182001.asp