// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#using <mscorlib.dll>

#include <iostream> 
#include <string>

int main()
{
    std::string s1 = "ABC";
    std::cout << s1 << std::endl;
    System::String^ s2 = "DEF";
    System::Console::WriteLine(s2);
    System::String^ s3 = gcnew System::String(s1.substr(0,2).c_str());
    System::Console::WriteLine(s3);
    std::string s4 = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(s2->Substring(0,2));
    std::cout << s4 << std::endl;
    //missing System::Runtime::InteropServices::Marshal::FreeHGlobal call
    return 0;
}
