I have a class function in C# in which I want to pass a pointer to the current class as an argument in a call to another function:
public class SomeClass
{
public void SomeClassFunction()
{
SomeFunction(&this);
}
}
public void SomeFunction(SomeClass* ptr)
{
}
I have very little C# experience, and I'm using Visual Studio 2022.
Doing &this
results in CS0211: Cannot take the address of the given expression
.
Doing *this
results in CS0193: The * or -> operator must be applied to a pointer
.
What is the proper way to pass a pointer to the current class from a class function?
Thanks for reading my post, any guidance is appreciated.