• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

Problem with the part

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

2 Solutions
AndyAinscowFreelance programmer / ConsultantCommented:
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.
str1.GetType() returns string

If you want to know if it is a numeric value have a look at:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now