In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn't appear to be part of Oxygene, and I can't find a reference to something that can do that. How can it be done?
Asked
Active
Viewed 7,907 times
1
-
2Delphi Prism is a compiler. It does not contain a library like Delphi win32 does. When using Delphi Prism you can use the full range of .Net classes and methods in the .Net library. It is the same library that C# and VB.Net uses. You might want to read about the subject in C# books or on http://msdn.microsoft.com/en-us/library/ms229335.aspx – Lars Truijens Nov 09 '09 at 21:33
-
@Lars - That's not entirely accurate. Delphi Prism ships with a handful of DB connectivity components and design tools. So its not just a compiler. – Kenneth Cochran Jul 27 '10 at 16:56
2 Answers
9
You can use the Int32.Parse function
try this
function StrToInt(S: String): Integer;
begin
Result:=Int32.Parse(S);
end;
.Parse is pretty richly supported for multiple types.

Jim McKeeth
- 38,225
- 23
- 120
- 194

RRUZ
- 134,889
- 20
- 356
- 483
-
3You can also use Int32.TryParse(S, out intVariable) which returns a boolean indicating whether parsing the string into an integer was successful. – Sebastian P.R. Gingter Nov 11 '09 at 16:49
4
RRUZ has the correct answer, but if you can't say good-bye to all the functions and classes you where used to in Delphi win32 you could take a look at ShineOn. It's an open source library written in Delphi Prism to port Delphi win32 functions and classes to .Net. Not surprisingly it also contains IntToStr and StrToInt.

Jim McKeeth
- 38,225
- 23
- 120
- 194

Lars Truijens
- 42,837
- 6
- 126
- 143