TheLearnedOne (Bob) : Our First Genius

Posted on 2006-07-13
Last Modified: 2010-05-18
For 200 points to put you over ... How do I get an integer from a string (i.e. I have "45" in a textbox)


I think we all know that points aren't that important to you but congratulations on being our first genius!


Greg Young
Question by:gregoryyoung

Expert Comment

ID: 17099944
ooh... ooh! I know this one... um... it's something like

something like:

string str = "";
int txtLen = textBox1.Text.Length;

foreach(char c in textBox1.Text.ToCharArray(0, txtLen ))
      str += c;
char[] ints = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

foreach(char c in str.ToCharArray())
      if(Array.IndexOf(ints, c) < 0)
            MessageBox.Show("Not a valid int");

//valid if it makes it this far
int i = Convert.ToInt32(Convert.ToString(Convert.ToString(str.ToString()).ToString().ToString()).ToString());


Ah, just kidding, Congrats Bob!!!
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 17101032
Good job Bob!   =)

Expert Comment

ID: 17101041
Just wanna add my congrats too!
Great work mate!
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

LVL 96

Expert Comment

by:Bob Learned
ID: 17102152
Hey, Greg, I have a question open about serialization, and I know that you know a lot about the subject, and I would like to hear what you have to say.

P.S.  I'll take my points the good ol' fashion way, if you don't mind.  One more question and I am home free for genius #3.  These people around here are driving me crazy, though, cuz I have posted a lot of suggestions and good comments, but it is sooo quiet today, it just creeps up to just below 1000000.

LVL 44

Expert Comment

ID: 17106854
Congrats Bob,

a good excuse to thank you for all the cleanup you're doing as an aside :)

LVL 96

Accepted Solution

Bob Learned earned 20 total points
ID: 17107572
Aah, yes, thank you Brian for recognizing the need for cleanup--it's a tough job, but somebody has to do it!!! *BIG GRIN*


Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question