Solved

Problem with the part

Posted on 2013-10-22
2
309 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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…
Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

729 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