一.在类中使用Request,Response,Application对象时,前面要加上HttpContext.Current
例:HttpContext.Current.Application["GuestBook_TimeOut"]
二.string vldLength = Regex.Replace(guestbook_details, "[\u4e00-\uf900]", "aa");
此句的意思是将regex.replace按照里面的"[\u4e00-\uf900]"这个正则表达式返回字符串的长度,中文为2字节,英文为1字节
三. 很重要三层构架中必须用到这个..主要是DataSet比较好分页
/// <summary>
/// Ilist<T> 转换成 DataSet
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
static public DataSet ConvertToDataSet<T>(IList<T> list)
{
#region
if (list == null || list.Count <= 0)
{
return null;
}
DataSet ds = new DataSet();
DataTable dt = new DataTable(typeof(T).Name);
DataColumn column;
DataRow row;
System.Reflection.PropertyInfo[] myPropertyInfo = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
foreach (T t in list)
{
if (t == null)
{
continue;
}
row = dt.NewRow();
for (int i = 0, j = myPropertyInfo.Length; i < j; i++)
{
System.Reflection.PropertyInfo pi = myPropertyInfo[i];
string name = pi.Name;
if (dt.Columns[name] == null)
{
column = new DataColumn(name, pi.PropertyType);
dt.Columns.Add(column);
}
row[name] = pi.GetValue(t, null);
}
dt.Rows.Add(row);
}
ds.Tables.Add(dt);
return ds;
#endregion
}
浙公网安备 33010602011771号