Even though C# allows pointers in 'unsafe' mode, this is not a good practice for converting C++ code to C#. Below is the conversion to idiomatic C#.
Foo *f1 = new Foo();
std::shared_ptr<Foo> f2 = std::make_shared<Foo>();
|Foo f1 = new Foo();
Foo f2 = new Foo();
Use C++ to C# Converter to convert from C++ to C#.
C++ and C# Equivalents
Copyright © 1997 – 2018 Tangible Software Solutions Inc.