Mega Code Archive

 
Categories / Visual C++ .NET / Data Type
 

Parse and get the double value

#include "stdafx.h" using namespace System; int main() {    String^ str1 = "115";    String^ str2 = "1.4e-12";    int i = Int32::Parse( str1 );    double x = Double::Parse( str2 );    //     int j = Convert::ToInt32( str1 );    double y = Convert::ToDouble( str2 );    try    {       int k = Int32::Parse("bad format");    }    catch(FormatException^ e)    {        Console::WriteLine("Exception occurred! {0}", e->Message );    } }