
| int ival = 0; Int32 ival2 = 0; |
| 基本类型 | System命名空间中对应的类 | 注释/用法 |
| bool | System::Boolean | bool dirty = false; |
| char | System::SByte | char sp = ' '; |
| signed char | System::SByte | signed char ch = -1; |
| unsigned char | System::Byte | unsigned char ch = '\0'; |
| wchar_t | System::Char | wchar_t wch = ch; |
| short | System::Int16 | short s = ch; |
| unsigned short | System::UInt16 | unsigned short s = 0xffff; |
| int | System::Int32 | int ival = s; |
| unsigned int | System::UInt32 | unsigned int ui = 0xffffffff; |
| long | System::Int32 | long lval = ival; |
| unsigned long | System::UInt32 | unsigned long ul = ui; |
| long long | System::Int64 | long long etime = ui; |
| unsigned long long | System::UInt64 | unsigned long long mtime = etime; |
| float | System::Single | float f = 3.14f; |
| double | System::Double | double d = 3.14159; |
| long double | System::Double | long double d = 3.14159L; |
| int imaxval = int::MaxValue; int iminval = Int32::MinValue; |
| String^ bonus = "$ 12,000.79"; |
| double myBonus = double::Parse( bonus, ns ); |
| using namespace System; using namespace System::Globalization; double bonusString( String^ bonus ) { NumberStyles ns = NumberStyles::AllowLeadingWhite; ns |= NumberStyles::AllowCurrencySymbol; ns |= NumberStyles::AllowThousands; ns |= NumberStyles::AllowDecimalPoint; return double::Parse( bonus, ns ); } |
| int ival = ( int ) myBonus; |
| int ival2 = Convert::ToInt32( myBonus ); |
| Console::Write( "{0} : ", ( 5 ).ToString() ); |
| Console::WriteLine(( 'a' ).ToString() ); |
| Console::WriteLine(((wchar_t)'a').ToString() ); |
| public ref class R { public: void foo( System::String^ ); // (1) void foo( std::string ); // (2) void foo( const char* ); // (3) }; void bar( R^ r ) { // 调用哪一个foo呢? r->foo( "Pooh" ); } |
| 关于我们 | 联系我们 | 广告服务 | 工作机会 | 版权声明 | 欢迎投稿 | 网站地图 |
| Copyright © 2000-2008 , www.21tx.com , All Rights Reserved . |
| © 晨新科技 版权所有 Created by TXSite.net |