Search code examples
c++-clitype-conversionint32

Visual C++ 2010 -> Window Form. How to convert string to int?


Hey! I have textBox with text like "12:30" and this code textBox -> Text -> ToString() -> Split(':')[1] It return "30" as string. And I want convert it to Int. How? I founded function like Convert::ToInt32() etc, but it doesnt work for my c++ (Visual C++ 2010 -> Winfow Form). Help me plz! (I started learn c++ 2 days ago)

And i use Managed C++


Solution

  • As you're using Managed C++, then you can do this:

    double foo = System::Convert::ToDouble("200");
    int bar = System::Convert::ToInt32("200");
    

    Use whatever you need!