"C #" integer type of judgment!

Source: Internet
Author: User
I am in the application of C # to do project when I think, textbox text box in the value of the type of judgment is not convenient, in the C#bbs to find whether there is such a class or function, but I am disappointed! So with a dull head wrote a test situation is also very satisfied, take let netizen pointing twos, if there is better, look at lease teach! Shixiang9076@sina.com.

Using System;
Using System.Drawing;
Using System.Collections;
Using System.ComponentModel;
Using System.Windows.Forms;
Using System.Data;

Namespace Winmarket
{
<summary>
Summary description of the Classfun.
</summary>
public class Classfun
{
private bool Isbool;

Public Classfun ()
{
//
TODO: Add constructor logic here
//
}
----------judge whether it is an integer-----------------
public bool Isint (string tbstr)
{
String sign= "+-";
String intstr= "1234567890";
String intsign;
int intstrsub,intindex;
int intbool=0;
Tbstr=tbstr.trim ();
if (tbstr.length==1)
{
Intstrsub=intstr.indexof (TBSTR);
if (intstrsub!=-1)
{
intbool=0;
}
Else
{
intbool=1;
}
}
else if (tbstr.length>1)
{Intindex=tbstr.indexof (".");
if (intindex==-1)
{
for (int i=0;i<=tbstr.length-1;i++)
{
intsign= tbstr.substring (i,1). ToString ();
Intstrsub=intstr.indexof (intsign);
if (i==0)
{
if (intstrsub!=-1)
{
if (intstrsub!=9)
{
intbool=0;
}
Else
{
intbool=i+1;
Break
}
}
Else
{
if (intsign== "-" | | intsign== "+")
{
intbool=0;

}
Else
{
intbool=i+1;
Break
}
}

}
Else
{
if (intstrsub!=-1)
{
intbool=0;
}
Else
{
intbool=i+1;
}

}
}


}

Else
{
intbool=1;
}
}

if (intbool==0)
{
Isbool=true;
}
Else
{
Isbool=false;
}
return isbool;

}



}
}





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.