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!
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
WPF issue with Trigger 2 67
Refresh Datagridview from another form 1 28
getting id from database 5 24
cs.Designer Issue 2 17
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now