Solved

Problem with the part

Posted on 2013-10-22
2
305 Views
Last Modified: 2013-10-22
Hi,
While str1 is having 5 inside, I believe it should not go to the codes under 2nd if-line below. But it does. why?
            string str1 = tb_ite.Text;
            if (tb_ite.Text.Trim() != "")
            {
                if ((!(str1.GetType() == typeof(int))) && (!(str1.GetType() == typeof(double))) && (!(str1.GetType() == typeof(long))) && (!(str1.GetType() == typeof(short))) && (!(str1.GetType() == typeof(float))))
                {
                    ...

Open in new window

0
Comment
Question by:HuaMinChen
2 Comments
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 45 total points
ID: 39590356
str1.GetType() will ALWAYS return the same type - a string because str1 is a string variable.

Your code is very likely not what you want to do.
0
 
LVL 7

Accepted Solution

by:
tipsybroom earned 45 total points
ID: 39592128
str1.GetType() returns string

If you want to know if it is a numeric value have a look at:
http://www.codeproject.com/Articles/16329/C-Equivalent-of-VB-s-IsNumeric
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this article you will learn how to create a free basic website on Bitbucket, a git service provider. Polymer creates dynamic HTML components, which allow more flexibility than static HTML. This tutorial uses Ubuntu Linux but can also be done on W…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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