zoukankan
html css js c++ java
c#字符串操作辅助类
Code
/**/
/**/
/**/
///
<summary>
///
字符串操作辅助类
///
</summary>
public
class
StringUtil
{
一些基本的符号常量
#region
一些基本的符号常量
/**/
/**/
/**/
///
<summary>
///
点符号 .
///
</summary>
public
const
string
Dot
=
"
.
"
;
/**/
/**/
/**/
///
<summary>
///
下划线 _
///
</summary>
public
const
string
UnderScore
=
"
_
"
;
/**/
/**/
/**/
///
<summary>
///
逗号加空格 ,
///
</summary>
public
const
string
CommaSpace
=
"
,
"
;
/**/
/**/
/**/
///
<summary>
///
逗号 ,
///
</summary>
public
const
string
Comma
=
"
,
"
;
/**/
/**/
/**/
///
<summary>
///
左括号 (
///
</summary>
public
const
string
OpenParen
=
"
(
"
;
/**/
/**/
/**/
///
<summary>
///
右括号 )
///
</summary>
public
const
string
ClosedParen
=
"
)
"
;
/**/
/**/
/**/
///
<summary>
///
单引号 '
///
</summary>
public
const
string
SingleQuote
=
"
\'
"
;
/**/
/**/
/**/
///
<summary>
///
斜线 \
///
</summary>
public
const
string
Slash
=
@"
\
"
;
#endregion
private
StringUtil()
{
}
/**/
/**/
/**/
///
<summary>
///
移除空格并首字母小写的Camel样式
///
</summary>
///
<param name="name"></param>
///
<returns></returns>
public
static
string
ToCamel(
string
name)
{
string
clone
=
name.TrimStart(
'
_
'
);
clone
=
RemoveSpaces(ToProperCase(clone));
return
String.Format(
"
{0}{1}
"
, Char.ToLower(clone[
0
]), clone.Substring(
1
, clone.Length
-
1
));
}
/**/
/**/
/**/
///
<summary>
///
移除空格并首字母大写的Pascal样式
///
</summary>
///
<param name="name"></param>
///
<returns></returns>
public
static
string
ToCapit(
string
name)
{
string
clone
=
name.TrimStart(
'
_
'
);
return
RemoveSpaces(ToProperCase(clone));
}
/**/
/**/
/**/
///
<summary>
///
移除最后的字符
///
</summary>
///
<param name="s"></param>
///
<returns></returns>
public
static
string
RemoveFinalChar(
string
s)
{
if
(s.Length
>
1
)
{
s
=
s.Substring(
0
, s.Length
-
1
);
}
return
s;
}
/**/
/**/
/**/
///
<summary>
///
移除最后的逗号
///
</summary>
///
<param name="s"></param>
///
<returns></returns>
public
static
string
RemoveFinalComma(
string
s)
{
if
(s.Trim().Length
>
0
)
{
int
c
=
s.LastIndexOf(
"
,
"
);
if
(c
>
0
)
{
s
=
s.Substring(
0
, s.Length
-
(s.Length
-
c));
}
}
return
s;
}
/**/
/**/
/**/
///
<summary>
///
移除字符中的空格
///
</summary>
///
<param name="s"></param>
///
<returns></returns>
public
static
string
RemoveSpaces(
string
s)
{
s
=
s.Trim();
s
=
s.Replace(
"
"
,
""
);
return
s;
}
/**/
/**/
/**/
///
<summary>
///
字符串首字母大写
///
</summary>
///
<param name="s"></param>
///
<returns></returns>
public
static
string
ToProperCase(
string
s)
{
string
revised
=
""
;
if
(s.Length
>
0
)
{
if
(s.IndexOf(
"
"
)
>
0
)
{
revised
=
Strings.StrConv(s, VbStrConv.ProperCase,
1033
);
}
else
{
string
firstLetter
=
s.Substring(
0
,
1
).ToUpper(
new
CultureInfo(
"
en-US
"
));
revised
=
firstLetter
+
s.Substring(
1
, s.Length
-
1
);
}
}
return
revised;
}
/**/
/**/
/**/
///
<summary>
///
判断字符是否NULL或者为空
///
</summary>
public
static
bool
IsNullOrEmpty(
string
value)
{
if
(value
==
null
||
value
==
string
.Empty)
{
return
true
;
}
return
false
;
}
}
查看全文
相关阅读:
Dockerfile 构建前端node应用并用shell脚本实现jenkins自动构建
Nginx自定义404页面
shell脚本逐个杀死k8s中某个应用的pod
阿里云容器镜像加速器配置
jenkins shell脚本自动化构建阿里云k8s上应用
在容器服务kubernetes上配置https
docker build 指定dockerfile
centos 7 系统启动不了 出现报错dependency failed for /mnt , dependency failed for local file systems
向Kubernetes集群删除Node
SharePoint 2013 关于自定义显示列表表单的bug
原文地址:https://www.cnblogs.com/xiexiaokui/p/1246567.html
最新文章
Mysql 中的事件//定时任务
Mysql中的函数
Mysql中的存储过程
mysql之触发器trigger
Mysql中的触发器
Mysql中的视图
PHP断点调试工具Xdebug的安装
php反射获取类和方法中的注释
ARM与x86之3--蝶变ARM
vue组件介绍
热门文章
C#获取相对路径[转]
C#中的数组【转】
C#视频播放器【转】
C#使用DirectShow播放视频文件 [转]
DGN格式转化为shp格式 【转】
对开源库使用 AutoCAD 文件格式[转]
使用CadLib实现CAD(dxf、dwg格式)文件的读取和显示 【转】
c#如何操作ppt的播放 【转】
切线空间(Tangent Space)法线映射(Normal Mapping)【转】
Dockerfile 构建前端nginx应用并用shell脚本实现jenkins自动构建
Copyright © 2011-2022 走看看