///
/// Is the date format correct?
/// summary>
#Region Public String IsdateFormat (String StRDATE)
Public string isdateFormat (String strdate)
{
STRDATE = strdate.trim ();
Regex r1 = new regex (@ "^ (?
Regex r2 = new regex (@ "^ (?
Regex R3 = New Regex (@ "^ (?
Regex R4 = New Regex (@ "^ (?
// Year, month, day
String year, month, date;
IF (regex.ismatch (@ "^ (?
{
Year = r4.match (strdate) .result ("$ {year}");
Month = r4.match (strdate) .result ("$ {month}");
Date = r4.match (strdate) .Result ("$ {day}");
}
Else IF (regex.ismatch (@ "^ (?
{
Year = r1.match (strdate) .result ("$ {year}");
Month = r1.match (strdate) .result ("$ {month}");
Date = r1.match (strdate) .Result ("$ {day}");
}
Else IF (regex.ismatch (@ "^ (?
{
Year = r2.match (strdate) .result ("$ {year}");
Month = r2.match (strdate) .Result ("$ {month}");
Date = r2.match (strdate) .Result ("$ {day}");
}
Else if (stradate, @ "^ (?
Year = r3.match (strdate) .result ("$ {year}");
Month = r3.match (strdate) .result ("$ {month}");
Date = r3.match (strdate) .Result ("$ {day}");
}
Else
{
Return "Error";
}
// Last check of the date of the date
Try
{
System.datetime DT = New DateTime (Convert.Toint32 (Year), Convert.Toint32 (Month), Convert.Toint32 (Date);
Return Dt.toString ("YYYY-MM-DD");
}
Catch
{
Return "Error";
}
}
#ndregion
-------------------------------------------------- ----------------------------------------
///
/// Test if the Email string format is correct
/// summary>
#Region Public Bool ISEMAILFORMAT (String Stree)
Public Bool IsemailFormat (String Stree)
{
Return regex.ismatch (stremail, @ "^ ([/ w - /.] ) @ (/ [[0-9] {1, 3} /. [0-9] {1, 3} /. 0-9] {1,3} /.) | ([/ W -] /.) )) ([A-ZA-Z] {2, 4} | [0-9] {1,3 }) (/]?) $ ");
}
#ndregion
-------------------------------------------------- ----------------------------------------
///
/// Convert Fifteen ID cards to the 18th function.
/// summary>
#REGON PUBLIC STRING ConvertIDCARD15TO18 (String Strtemp)
Public String ConvertIDCARD15TO18 (String Strtemp)
{
Int [] arrint = new int [] {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
String arrCh = "10x98765432";
INT NTEMP = 0;
IF (strTemp.length == 15)
{
Strtemp = startemp.substring (0,6) "19" strTemp.substring (6, strTemp.length-6);
For (int i = 0; i { Ntemp = int.parse (strtemp.substring (i, 1) .tostring ()) * arrint [i]; } STRTEMP = Arrch [ntemp% 11]; } Char DD = Arrch [NTEMP% 11]; RETURN STRTEMP; } #ndregion -------------------------------------------------- ---------------------------------------- In order to determine the function group of the ASCII code, only support /// / / Is whether it is a double-byte character. /// summary> Public Static Bool Istwobyteschar (Char CHR) { String str = chr.tostring (); // Use Chinese to support the encoding Encoding ecode = encoding.getencoding ("GB18030"); IF (ecode.getbytecount (str) == 2) { Return True; } Else { Return False; } } /// /// get the ASCII code of the character /// summary> Public Static Int ASCII (Char CHR) { Encoding ecode = encoding.getencoding ("GB18030"); Byte [] codebytes = ecode.getbytes (chr.tostring ()); IF (ISTWOBYTESCHAR (CHR)) { // Double-nature code is high by 256, plus low / / Should be no symbol, then reduce 65536 Return (int) codebytes [0] * 256 (int) codebytes [1] - 65536; } Else { Return (int) codebytes [0]; } }