基础公用函数(整理中)
来源:互联网 发布:我国域名管理机构 编辑:程序博客网 时间:2024/05/17 09:31
//换行
public string GetLength(string str)
{
string s = "";
string s2 = "";
if (str.Length > 40)
{
int j = str.Length / 40 + 1;
int z = str.Length % 40;
int o = j - 1;
for (int i = 0; i < j; i++)
{
if (i == j - 1)
{
s2 = s2 + str.Substring(o * 40, z);
}
else
{
int l = i * 40;
s = str.Substring(l, 40);
s2 = s2 + s + "<br/>";
}
}
return s2;
}
else
{
return str;
}
}
/// <summary>
/// 半角(DBC case)转全角(SBC case)
/// </summary>
/// <param name="source">被转换的半角字符串</param>
/// <returns>转换后的全角字符串</returns>
static string DBC2SBC(string source)
{
//袁晓辉(http://blog.csdn.net/uoyevoli) 整理
byte[] bytes = Encoding.Unicode.GetBytes(source);
for (int i = 0; i < bytes.Length; i += 2)
{
if (bytes[i + 1] == 0)
{
bytes[i] -= 32;
bytes[i + 1] = 255;
}
}
return new string(Encoding.Unicode.GetChars(bytes));
}
// Helper routine that logs SqlException details to the
// Application event log
private void LogException( SqlException sqlex )
{
EventLog el = new EventLog();
el.Source = "CustomAppLog";
string strMessage;
strMessage = "Exception Number : " + sqlex.Number +
"(" + sqlex.Message + ") has occurred";
el.WriteEntry( strMessage );
foreach (SqlError sqle in sqlex.Errors)
{
strMessage = "Message: " + sqle.Message +
" Number: " + sqle.Number +
" Procedure: " + sqle.Procedure +
" Server: " + sqle.Server +
" Source: " + sqle.Source +
" State: " + sqle.State +
" Severity: " + sqle.Class +
" LineNumber: " + sqle.LineNumber;
el.WriteEntry( strMessage );
}
- 基础公用函数(整理中)
- 公用函数(1)
- 公用函数
- 公用函数
- 基础命令-(整理中)
- artTemplate访问外部公用函数(二)
- libevent基础函数整理
- Python基础函数整理
- 基础整理-函数
- pb基础公用代码
- Java 基础问题整理(更新中)
- 中特基础整理
- JavaScript公用函数
- 一些公用js函数
- 我的公用函数
- delphi公用函数
- 公用sqlcommand 函数
- ajax请求公用函数
- Linux中Route命令
- tomcat 发布多个项目时抛的webAppRootKey错误
- QQ界面编程,绝佳的学习材料
- 关于struts2中对 request session application 的访问
- 金山与360
- 基础公用函数(整理中)
- JVM内存模型以及垃圾回收
- provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接
- InterLocked的几个函数
- Android应用 网站SEO信息查询工具~~终于完成了
- hibernate实体对象生命周期
- Fedora13 U盘启动+硬盘安装
- Qt国际化步骤
- Oracle的redo 和undo的区别