?
Solved

Problem with the part

Posted on 2013-10-22
2
Medium Priority
?
310 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 180 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 180 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

A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

764 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