CheckData字元類方法 字串操作 4

2021-04-13 02:48:25 字數 1861 閱讀 2650

///

/// 檢查字串最大長度,返回指定長度的串

///

///

///

///

public static string sqltext(string sqlinput, int maxlength)

}return sqlinput;

} ///

/// 檢查從頁面輸入的字串,防止sql注入攻擊

///

///

///

public static string checkstring(string sour)

///

/// 比較兩個 double 值 的大小返回 1|0|-1

///

///

///

///

public static int comparedouble(double a, double b)

if (a > b)

return -1;

}///

/// if true then return 1 else return 0

///

///

///

public static string convertbooltostring(bool istrue)

return "0";

}///

/// 將空值轉換為"0"

///

///

///

public static string convertemptyto0(object key)

if (key.tostring() == "")

return key.tostring();

}///

/// if value is null or "" ,return "0"

///

///

///

public static string convertemptyto0(string key)

return "0";

}///

/// if 1 then return true else return false

///

///

///

public static bool convertstringtobool(string key)

///

/// 返回有兩位小數的字串,eg: 1,234,567.89        為0則返回空

///

///

///

public static string formatdouble(double num)

return string.format("", num);

}///

/// 返回有兩位小數的字串 eg: 1,234,567.89        為0則返回 0.00,且無千位分隔符

///

///

/// 是否將"0"轉成"",default:true

///

public static string formatdouble(object num, bool iszerotoempty)

try", todouble(num));

}catch

}///

/// 返回有兩位小數的字串 eg: 1,234,567.89    為0則返回空

///

///

///

public static string formatdouble(object num)

catch

CheckData字元類方法 字串操作 1

類擬substring一樣eg getcountstring abcde 1,3 返回bcd public string getcountstring string lzpstr,int startindex,int length if length bytes.length startindex ...

CheckData字元類方法 字串操作 6

region fields private static regex regdecimal private static regex regchzn private static regex regdecimalsign private static regex regemail private s...

php 類 方法關鍵字

1 final 如果我們不希望乙個類被繼承,我們使用final來修飾這個類。這個類將無法被繼承。final 用於類 方法前。final類 不可被繼承。final方法 不可被覆蓋。2 public 表示全域性,類內部外部子類都可以訪問 private表示私有的,只有本類內部可以使用 protected...