In my c# application i receive pointer to c++ struct in callback/delegate. I\'m not sure if class
can do the trick but just casting c++ pointer to appropriate c
It sounds like you just want to use ref
to pass the struct by reference:
private static void Foo(ref s s1)
{
s1.a++;
Console.WriteLine("inner a = " + s1.a);
}
And at the call site:
Foo(ref s1);
See my article on parameter passing in C# for more details.
Note that other than for interop, I would normally strongly recommend against using mutable structs like this. I can understand the benefits here though.