Visual C++ .NET/Development/Convert — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 18:31, 26 мая 2010
Use Convert class to convert the value
<source lang="csharp">
- 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 ); }
}
</source>