总结12C#常用的类Word格式.docx

上传人:b****4 文档编号:17875919 上传时间:2022-12-11 格式:DOCX 页数:24 大小:19.61KB
下载 相关 举报
总结12C#常用的类Word格式.docx_第1页
第1页 / 共24页
总结12C#常用的类Word格式.docx_第2页
第2页 / 共24页
总结12C#常用的类Word格式.docx_第3页
第3页 / 共24页
总结12C#常用的类Word格式.docx_第4页
第4页 / 共24页
总结12C#常用的类Word格式.docx_第5页
第5页 / 共24页
点击查看更多>>
下载资源
资源描述

总结12C#常用的类Word格式.docx

《总结12C#常用的类Word格式.docx》由会员分享,可在线阅读,更多相关《总结12C#常用的类Word格式.docx(24页珍藏版)》请在冰豆网上搜索。

总结12C#常用的类Word格式.docx

{

///取得大写中文字

paramname="

strCode"

>

数字如1、2、3<

/param>

returns>

<

/returns>

remarks>

/remarks>

publicstaticstringGetBigTWNum(stringstrCode)

stringstrReData;

switch(strCode)

case"

1"

:

strReData="

壹"

;

break;

2"

贰"

3"

参"

4"

肆"

5"

伍"

6"

陆"

7"

柒"

8"

捌"

9"

玖"

0"

零"

default:

"

}

returnstrReData;

 

///将阿拉伯数字转为国文数字

strNum"

阿拉伯数字(例:

15)<

转换后的中文数字(例:

十五)<

Author:

Peter2006/8/17<

publicstaticstringNumToChn(stringstrCode)

if(strCode==null||strCode=="

return"

if(strCode.Length==1)

一"

二"

三"

四"

五"

六"

七"

八"

九"

elseif(strCode.Length==2)

if(strCode=="

10"

十"

elseif(strCode=="

20"

||strCode=="

30"

40"

50"

60"

90"

70"

80"

strReData=NumToChn(strCode.Substring(0,1))+"

elseif(Convert.ToInt16(strCode)<

20&

&

Convert.ToInt16(strCode)>

10)

+NumToChn(strCode.Substring(1,1));

100&

20)

else

elseif(strCode.Length==3)

100"

一百"

elseif(Convert.ToInt16(strCode)>

Convert.ToInt16(strCode)<

110||

200&

210||

300&

310||

400&

410||

500&

510||

600&

610||

700&

710||

800&

810||

900&

910)

百零"

+NumToChn(strCode.Substring(2,1));

110"

一百一十"

110&

120)

1000)

百"

+NumToChn(strCode.Substring(1,2));

///前缀补0

strValue"

要补零的字符串<

iLen"

设置补零后的字长<

补零后的字符串<

publicstaticstringAddPrefixZero(stringstrValue,intiLen)

inti;

i=strValue.Length;

while(i<

iLen)

strValue="

+strValue;

returnstrValue;

///<

///后缀补0

publicstaticstringAddSuffixZero(stringstrValue,intiLen)

strValue=strValue+"

///前缀去0

要去零的字符串<

去零后的字符串<

publicstaticstringRemovePrefixZero(stringstrValue)

stringoutValue;

for(inti=0;

i<

strValue.Length;

i++)

if(strValue.Substring(i,1)!

="

outValue=strValue.Substring(i,(strValue.Length-i));

returnoutValue;

///判断strNumber是否为数字,是数字返回True,不是数字返回False

strNumber"

要判断是否数字的字符串<

数字返回True,不是数字返回False<

publicstaticboolIsNumeric(StringstrNumber)

RegexNumberPattern=newRegex("

[^0-9.-]"

);

return!

NumberPattern.IsMatch(strNumber);

///连接功能处理

funName"

功能名称<

funNo"

功能编号<

ResponseTmp"

Response对象<

publicstaticvoidlinkFun(stringfunName,stringfunNo,ClientScriptManagerclientScriptTmp)

//判断是否有传入Http画面资料

if(clientScriptTmp==null)

return;

if(funNo.Length<

3)

//组成更改提示之javascript的语句

stringalertMeg;

alertMeg="

scriptlanguage='

javascript'

parent.statusbar.openFun('

alertMeg+=funName;

alertMeg+="

'

'

+funNo;

/script>

//画面上显示提示

clientScriptTmp.RegisterStartupScript(clientScriptTmp.GetType(),alertMeg,alertMeg);

///过滤[']和其它非法输入

press"

需判断之参数<

clientScriptTmp"

clientScript对象<

Ki添加2009/4/1<

publicstaticBooleancheckRule(stringpress,ClientScriptManagerclientScriptTmp)

stringc;

intj=0;

press.Length;

c=press.Substring(i,1).ToString();

if((c=="

)||(c=="

\\"

\"

-"

."

/"

))

funMessage.messageBox("

您输入的有非法字符!

clientScriptTmp);

j=1;

if(j==1)

returnfalse;

returntrue;

///转化为小数

publicstaticdoublestrToDouble(stringstrNum)

try

returndouble.Parse(strNum.Trim().ToString());

catch(System.Exceptionex)

return0;

///格式化数字成三字一撇的形式

传入的数值<

iLenDecimal"

保留的小数点<

publicstaticstringFormatNum(stringstrValue,intiValue)

stringstrRight,strLeft;

stringiLenDecimal;

stringa;

a=strValue.ToString().Substring(0,1);

iLenDecimal=strValue;

if(iLenDecimal.ToString().IndexOf("

0)>

0)

strRight=iLenDecimal.ToString().Substring(iLenDecimal.ToString().IndexOf("

0),iLenDecimal.ToString().Length-iLenDecimal.ToString().IndexOf("

0));

if(a=="

strLeft=iLenDecimal.ToString().Substring(1,iLenDecimal.ToString().IndexOf("

strLeft=iLenDecimal.ToString().Substring(0,iLenDecimal.ToString().IndexOf("

strRight="

strLeft=iLenDecimal.ToString();

intj=1;

inti=strLeft.ToString().Length;

while(i>

intiDecimal=funSystem.ToInt(iLenDecimal);

iLenDecimal=Convert.ToString(Convert.ToInt32(iDecimal/1000));

//stringstriLenDecimal=Convert.ToString(iLenDecimal);

i=Convert.ToString(iLenDecimal).Length;

strLeft=strLeft.ToString().Insert(strLeft.Length-(3*j),"

"

strLeft=strLeft.ToString().Insert(strLeft.Length-3*j-(j-1),"

j++;

if(strRight.Length==0)

for(intd=iValue;

d>

0;

d--)

strRight+="

if(iValue!

=0)

returnstrLeft.ToString()+"

+strRight.ToString();

returnstrLeft.ToString();

+funSystem.AddSuffixZero(strRight.Substring

(1),iValue);

/////<

/////格式化数字成三字一撇的形式

str"

//publicstaticstringFormatNum(stringstr)

//{

//string[]strA=newstring[2];

//strA=str.Split('

.'

//string[]strB=newstring[2];

//strB=str.Split('

-'

//if(strA.Length>

=2)

//{

//str=strA[0];

//}

//elseif(strB.Length>

//str=strB[1];

//Regexrg=newRegex("

\\d{3}"

RegexOptions.RightToLeft);

//MatchCollectionmc=rg.Matches(str);

//if(str.Trim().Length%3==0)

//for(inti=0;

mc.Count-1;

//str=str.Insert(mc[i].Index,"

//else

mc.Count;

//str=str+'

+strA[1];

//str='

+str;

//returnstr;

//}

传入数字(如:

1000或是1000.12)

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 人文社科 > 教育学心理学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1