Click to See Complete Forum and Search --> : System::string to int


Rayman2
January 3rd, 2006, 12:19 PM
is there any way to convert system::string^ to int? :(


using visual studo 2k5 (VC++)

suresha_psg
January 3rd, 2006, 12:22 PM
You can extract character by character and subtract the ascii value and multiply by 10 each time and add it. Hope this helps

wildfrog
January 3rd, 2006, 12:27 PM
You can do it like this:

System::String^ str = L"123";

// parse integer
__int32 i = System::Int32::Parse(str);

- petter

Rayman2
January 3rd, 2006, 12:46 PM
You can do it like this:

System::String^ str = L"123";

// parse integer
__int32 i = System::Int32::Parse(str);

- petter


tnx it worked well :D

can you tell mi the diference betwin int and __int32 :S my function is taking int
but it taked __int32 as well :S and i cant see any diference betwen those two :S

:)

humptydumpty
January 3rd, 2006, 01:46 PM
Microsoft C/C++ features support for sized integer types. You can declare 8-, 16-, 32-, or
64-bit integer variables by using the __intn type specifier, where n is 8, 16, 32, or 64.


__int8 nSmall; // Declares 8-bit integer
__int16 nMedium; // Declares 16-bit integer
__int32 nLarge; // Declares 32-bit integer
__int64 nHuge; // Declares 64-bit integer


The types __int8, __int16, and __int32 are synonyms for the ANSI types that have the
same size, and are useful for writing portable code that behaves identically across multiple
platforms. The __int8 data type is synonymous with type char, __int16 is synonymous with
type short, and __int32 is synonymous with type int. The __int64 type has no ANSI
equivalent.

Rayman2
January 3rd, 2006, 04:35 PM
oky thanx

NoHero
January 3rd, 2006, 06:17 PM
[ Moved Thread ]

humptydumpty
January 3rd, 2006, 11:57 PM
U always Welcome :p

NoHero
January 4th, 2006, 06:37 AM
Microsoft C/C++ features support for sized integer types. You can declare 8-, 16-, 32-, or
64-bit integer variables by using the __intn type specifier, where n is 8, 16, 32, or 64.

The types __int8, __int16, and __int32 are synonyms for the ANSI types that have the
same size, and are useful for writing portable code that behaves identically across multiple
platforms. The __int8 data type is synonymous with type char, __int16 is synonymous with
type short, and __int32 is synonymous with type int. The __int64 type has no ANSI
equivalent.

dotNet Alternative are:

System::Int16 nSmall;
System::Int32 nLarge;
System::Int64 nHuge;