📄 library.cs
字号:
return s.IndexOf(search, start < 0 ? 0 : start) + 1;
}
/**
* Method declaration
*
*
* @param s
*
* @return
*/
public static string ltrim(string s)
{
return s.TrimStart(null);
}
/**
* Method declaration
*
*
* @param s
* @param i
*
* @return
*/
public static string repeat(string s, int i)
{
if (s == null)
{
return null;
}
StringBuilder b = new StringBuilder();
while (i-- > 0)
{
b.Append(s);
}
return b.ToString();
}
/**
* Method declaration
*
*
* @param s
* @param replace
* @param with
*
* @return
*/
public static string replace(string s, string replace, string with)
{
if (s == null || replace == null)
{
return s;
}
if (with == null)
{
with = "";
}
StringBuilder b = new StringBuilder();
int start = 0;
int lenreplace = replace.Length;
while (true)
{
int i = s.IndexOf(replace, start);
if (i == -1)
{
b.Append(s);
break;
}
b.Append(s.Substring(start, i - start));
b.Append(with);
start = i + lenreplace;
}
return b.ToString();
}
/**
* Method declaration
*
*
* @param s
* @param i
*
* @return
*/
public static string right(string s, int i)
{
if (s == null)
{
return null;
}
i = s.Length - i;
return s.Substring(i < 0 ? 0 : i < s.Length ? i : s.Length);
}
/**
* Method declaration
*
*
* @param s
*
* @return
*/
public static string rtrim(string s)
{
return s.TrimEnd(null);
}
/**
* Method declaration
*
*
* @param s
*
* @return
*/
public static string soundex(string s)
{
if (s == null)
{
return s;
}
s = s.ToUpper();
int len = s.Length;
char[] b = new char[4];
b[0] = s.Substring(0,1).ToChar();
int j = 1;
for (int i = 1; i < len && j < 4; i++)
{
char c = s.Substring(i,1).ToChar();
if ("BFPV".IndexOf(c) != -1)
{
b[j++] = '1';
}
else if ("CGJKQSXZ".IndexOf(c) != -1)
{
b[j++] = '2';
}
else if (c == 'D' || c == 'T')
{
b[j++] = '3';
}
else if (c == 'L')
{
b[j++] = '4';
}
else if (c == 'M' || c == 'N')
{
b[j++] = '5';
}
else if (c == 'R')
{
b[j++] = '6';
}
}
return new string(b, 0, j);
}
/**
* Method declaration
*
*
* @param i
*
* @return
*/
public static string space(int i)
{
if (i < 0)
{
return null;
}
char[] c = new char[i];
while (i > 0)
{
c[--i] = ' ';
}
return new string(c);
}
/**
* Method declaration
*
*
* @param s
* @param start
* @param length
*
* @return
*/
public static string Substring(string s, int start, int length)
{
if (s == null)
{
return null;
}
int len = s.Length;
start--;
start = start > len ? len : start;
if (length == 0)
{
return s.Substring(start);
}
else
{
int l = length;
return s.Substring(start, start + l > len ? len : l);
}
}
/**
* Method declaration
*
*
* @param s
*
* @return
*/
public static string ucase(string s)
{
return s.ToUpper();
}
// TIME AND DATE
/**
* Method declaration
*
*
* @return
*/
public static DateTime curdate()
{
return DateTime.Now;
}
/**
* Method declaration
*
*
* @return
*/
public static DateTime curtime()
{
return DateTime.Now;
}
/**
* Method declaration
*
*
* @param d
*
* @return
*/
public static string dayname(SqlDateTime d)
{
return d.ToString();
}
/**
* Method declaration
*
*
* @param d
* @param part
*
* @return
*/
// private static int getDateTimePart(SqlDateTime d, int part)
// {
// Calendar c = new GregorianCalendar();
// c.setTime(d);
// return c.get(part);
// }
/**
* Method declaration
*
*
* @param d
*
* @return
*/
public static int dayofmonth(SqlDateTime d)
{
return d.Value.Day;
}
/**
* Method declaration
*
*
* @param d
*
* @return
*/
public static int dayofweek(SqlDateTime d)
{
return d.Value.DayOfWeek;
}
/**
* Method declaration
*
*
* @param d
*
* @return
*/
public static int dayofyear(SqlDateTime d)
{
return d.Value.DayOfYear;
}
/**
* Method declaration
*
*
* @param t
*
* @return
*/
public static int hour(SqlDateTime t)
{
return t.Value.Hour;
}
/**
* Method declaration
*
*
* @param t
*
* @return
*/
public static int minute(SqlDateTime t)
{
return t.Value.Minute;
}
/**
* Method declaration
*
*
* @param d
*
* @return
*/
public static int month(SqlDateTime d)
{
return d.Value.Month;
}
/**
* Method declaration
*
*
* @param d
*
* @return
*/
public static string monthname(SqlDateTime d)
{
return d.Value.Format("MMMM",null);
}
/**
* Method declaration
*
*
* @return
*/
public static DateTime now()
{
return DateTime.Now;
}
/**
* Method declaration
*
*
* @param d
*
* @return
*/
public static int quarter(SqlDateTime d)
{
return (d.Value.Month / 3) + 1;
}
/**
* Method declaration
*
*
* @param d
*
* @return
*/
public static int second(SqlDateTime d)
{
return d.Value.Second;
}
/**
* Method declaration
*
*
* @param d
*
* @return
*/
// public static int week(SqlDateTime d)
// {
// return getDateTimePart(d, Calendar.WEEK_OF_YEAR);
// }
/**
* Method declaration
*
*
* @param d
*
* @return
*/
public static int year(SqlDateTime d)
{
return d.Value.Year;
}
// SYSTEM
/**
* Method declaration
*
*
* @param conn
*
* @return
*
* @throws Exception
*/
/* public static string database(DBConnection conn)
{
Statement stat = conn.createStatement();
string s =
"SELECT Value FROM SYSTEM_CONNECTIONINFO WHERE KEY='DATABASE'";
ResultSet r = stat.executeQuery(s);
r.next();
return r.getstring(1);
}
*/
/**
* Method declaration
*
*
* @param conn
*
* @return
*
* @throws Exception
*/
/* public static string user(DBConnection conn)
{
Statement stat = conn.createStatement();
string s =
"SELECT Value FROM SYSTEM_CONNECTIONINFO WHERE KEY='USER'";
ResultSet r = stat.executeQuery(s);
r.next();
return r.getstring(1);
}
*/
/**
* Method declaration
*
*
* @param conn
*
* @return
*
* @throws Exception
*/
/* public static int identity(DBConnection conn)
{
DBCommand stat = new DBCommand();
conn.createStatement();
string s =
"SELECT VALUE FROM SYSTEM_CONNECTIONINFO WHERE KEY='IDENTITY'";
ResultSet r = stat.executeQuery(s);
r.next();
return r.getInt(1);
}
*/
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -