Judge Chinese Characters
CopyCode The Code is as follows: if (system. Text. encoding. getencoding ("gb2312"). getbytes ("medium"). Length = 2) // C #
If (escape (STR). indexof ("% u") <0) // Javascript
Judge Number
Copy code The Code is as follows: Number. As (v) // ezj
Number. asint (v) // ezj determines the integer
Determine pure numbers
Copy code The Code is as follows: Number. aspurenumber (v) // ezj determines a pure number (a positive or negative number or a decimal point is not allowed)
System. Text. regularexpressions. RegEx. ismatch (STR, @ "^ \ D + $") // C #
Leap year
Copy code The Code is as follows: if (Year % 4 = 0) & (Year % 100! = 0) | (Year % 400 = 0) // C #, JavaScript
If (Year mod 4 = 0) and (Year mod 100 <> 0) or (n mod 400 = 0) Then // ASP
Page number judgment
Copy code The Code is as follows: int totalpages = (totalrecords-1)/pagesize) + 1; // C #
Pagecnt = fix (recordcnt + pagesize-1)/pagesize) // ASP
[Code]
Others
[Code]
string STR = string. join (",", intlist. convertall (New converter (M => M. tostring ())). toarray ();
// C # string. join to int. The core is to convert int list to string list.
// It is simpler (. net 4):
string STR = string. join (",", intlist);