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
;
}
}
查看全文
相关阅读:
高斯消元学习
HDU 4596 Yet another end of the world(解一阶不定方程)
Codeforces Round #318 div2
HDU 4463 Outlets(一条边固定的最小生成树)
HDU 4458 Shoot the Airplane(计算几何 判断点是否在n边形内)
HDU 4112 Break the Chocolate(简单的数学推导)
HDU 4111 Alice and Bob (博弈)
POJ 2481 Cows(线段树单点更新)
HDU 4288 Coder(STL水过)
zoj 2563 Long Dominoes
原文地址:https://www.cnblogs.com/xiexiaokui/p/1246567.html
最新文章
数学建模算法(二):相关分析
数学建模算法(一):线性规划
LaTex学习笔记(一):review
数字信号处理实验(三):离散时间傅里叶变换
Matlab学习(一):数字图像处理大作业用到的函数
单片机TM4C123学习(十):ADC采样模块
单片机TM4C123学习(九):PWM
单片机TM4C123学习(八):SPI接口D/A
单片机TM4C123学习(七):I2C模块(温度传感器)
CF 515E, 线段树
热门文章
CF 351D, 离线处理+树状数组/莫队算法
CF 19D, 线段树套set/KD-tree
CF 338E, 线段树
CF 220E, 树状数组
CF 501D,树状数组+数学分析
CF 292E, 线段树
CF 474/F, 线段树 + 一点数学
SYSU-7, Gym 100273J, trie+hash
SYSU-7,Gym 100273J, Japanese Writing,hash
hihocoder #1014 : Trie树
Copyright © 2011-2022 走看看