The type judgment of "C #" Decimal!

Source: Internet
Author: User
Tags bool tostring
I write these kinds of methods or functions, it is inevitable that some errors or bugs exist, please do a lot of advice! 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 a decimal type------------

public bool Isdecimal (string TBstr0)
{
String intstr0= "1234567890";
String Intsign0,strint,strdecimal;
int intindex0,intsubstr,indexint;
int decimalbool=0;
int db=0;
BOOL BF,BL;
if (tbstr0.length>2)
{
Intindex0=tbstr0.indexof (".");
if (intindex0!=-1)
{
String strarr= ".";
Char[] Chararr=strarr.tochararray ();
String[] Numarr=tbstr0.split (Chararr);
Indexint=numarr.getupperbound (0);
if (indexint>1)
{
decimalbool=1;
}
Else
{
Strint=numarr[0]. ToString ();
STRDECIMAL=NUMARR[1]. ToString ();
---integral part--
if (strint.length>0)
{
if (strint.length==1)
{
Intsubstr=intstr0.indexof (Strint);
if (intsubstr!=-1)
{
Bf=true;
}
Else
{
Bf=false;
}
}
Else
{
for (int i=0;i<=strint.length-1;i++)
{
Intsign0=strint.substring (i,1). ToString ();
Intsubstr=intstr0.indexof (IntSign0);
if (intsubstr!=-1)
{
db=db+0;
}
Else
{
db=i+1;
Break
}
}

if (db==0)
{
Bf=true;
}
Else
{
Bf=false;
}
}
}
Else
{
Bf=true;
}
----A small number of parts--
if (strdecimal.length>0)
{
for (int j=0;j<=strdecimal.length-1;j++)
{
Intsign0=strdecimal.substring (j,1). ToString ();
Intsubstr=intstr0.indexof (IntSign0);
if (intsubstr!=-1)
{
db=db+0;
}
Else
{
db=j+1;
Break
}
}
if (db==0)
{
Bl=true;
}
Else
{
Bl=false;
}
}
Else
{
Bl=false;
}
if ((BF&AMP;&AMP;BL) ==true)
{
decimalbool=0;
}
Else
{
decimalbool=1;
}

}

}
Else
{
decimalbool=1;
}

}
Else
{
decimalbool=1;
}

if (decimalbool==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.