Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2007

Tip: Looking for answers? Try searching our database.

How can I make Console::ReadLine accepts int?  In other words.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Allen Maki - 29 Jun 2007 22:30 GMT
Hi everybody,

I need your help.

I am using Visual C++ .NET

How can I make Console::ReadLine accepts int?  In other words.

I know I can do this:

string* = Console::ReadLine();

Can anybody tell me how can I do this:

int = Console::Readline();
Peter Duniho - 29 Jun 2007 22:59 GMT
> [...]
> Can anybody tell me how can I do this:
>
> int = Console::Readline();

You can use the Parse() or Convert() methods to convert a string to an int.

Pete
Jesse Houwing - 30 Jun 2007 16:10 GMT
* Allen Maki wrote, On 29-6-2007 23:30:
> Hi everybody,
>
[quoted text clipped - 11 lines]
>
> int = Console::Readline();

In C# it would be something like this:

string i = Console.ReadLine();
int ii = -1;
if ( int32.TryParse(i, NumberStyles.Integer, out ii) )
{
    // do stuff with ii
}
else
{
    // print error?
}

It shouldn't be hard to convert that to c++ I guess.

Jesse

PS: Please, do not double post (one message for every group), but if you
absolutely need to post in different newsgroups at the same time, cross
post (address one message to multiple groups at once). That way answers
given in the other groups will automatically show up here as well.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.