📄 stringoperator.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Net;
using System.Text;
using System.IO;
using System.Collections;
/// <summary>
/// stringoperator 的摘要说明
/// </summary>
public class stringoperator
{
public stringoperator()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
#region 取子串
/// <summary>
/// 从一串字符串中取得指定长定的字符串
/// </summary>
/// <param name="sString"></param>
/// <param name="nLang"></param>
/// <returns></returns>
public string SubStr(string sString, int nLang)
{
if (sString.Length <= nLang)
{
return sString;
}
int nStrLeng = nLang - 1;
string sNewStr = sString.Substring(0, nStrLeng);
sNewStr = sNewStr + "....";
return sNewStr;
}
#endregion
#region
/// <summary>
/// 查询条件组合
/// </summary>
/// <param name="queryitems"></param>
/// <returns></returns>
public string GetConditionClause(Hashtable queryitems)
{
int count = 0;
string where = "";
foreach (DictionaryEntry item in queryitems)
{
if (count == 0)
{
where = " where ";
}
else
{
where += " and ";
}
if (item.Value.GetType().ToString()=="System.String"||item.Value.GetType().ToString()=="System.DataTime")
{
where += item.Key.ToString() + " like '%" + item.Value.ToString() + "%'";
}
else
{
where += item.Key.ToString() + "=" + item.Value.ToString();
}
count++;
}
return where;
}
#endregion
#region
/// <summary>
/// 查询条件组合
/// </summary>
/// <param name="queryitems"></param>
/// <returns></returns>
public string GetConditionClause(Hashtable queryitems,bool yes)
{
int count = 0;
string where = "";
foreach (DictionaryEntry item in queryitems)
{
if (count == 0)
{
where = " where ";
}
else
{
where += " and ";
}
if (item.Value.GetType().ToString()=="System.String"||item.Value.GetType().ToString()=="System.DataTime")
{
if (yes)
{
where += item.Key.ToString() + "='" + item.Value.ToString() + "'";
}
else
{
where += item.Key.ToString() + " like '%" + item.Value.ToString() + "%'";
}
}
else
{
where += item.Key.ToString() + "=" + item.Value.ToString();
}
count++;
}
return where;
}
#endregion
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -