我爱Aspx >> Asp.Net >> C#里面全角和半角的自由转换半角转全角:
c="hello World".ToCharArray();
for (int i=0;i<c.Length;i++)
{
byte[] b=System.Text.Encoding.Unicode.GetBytes(c,i,1);
if (b.Length= =2)
{
if (b[1]= =0)
{
b[0]=(byte)(b[0]-32);
b[1]=255;
c[i]=System.Text.Encoding.Unicode.GetChars(b)[0];
}
}
}
string strNew=new string(c);
全角转半角:
string QJstr = "hello,Amigo quanjiao字符";
char[] c=QJstr.ToCharArray();
for (int i=0;i<c.Length;i++)
{
byte[] b=System.Text.Encoding.Unicode.GetBytes(c,i,1);
if (b.Length= =2)
{
if (b[1]= =255)
{
b[0]=(byte)(b[0]+32);
b[1]=0;
c[i]=System.Text.Encoding.Unicode.GetChars(b)[0];
}
}
}
string strNew=new string(c);
Ҷƪл˵?
C#操作注册表[05-20]
最简单的字符串加密C#实现-移位..[05-20]
C#中字符串的加密[05-20]
用C#获取硬盘序列号,CPU序列号,网..[05-20]
c#如何获得cpu,硬盘的物理序列号[05-20]
使用C#实现阿拉伯数字到大写中文..[05-20]
C#(IsNumeric) 字符串转换为数字..[05-20]
深入理解C#编程中的组件-事件-委..[05-20]
C#中一些字符串操作的常用用法[05-20]
C#里的InputBox[05-20]
C#操作注册表[05-20]
最简单的字符串加密C#实现-移位..[05-20]
C#中字符串的加密[05-20]
用C#获取硬盘序列号,CPU序列号,网..[05-20]
c#如何获得cpu,硬盘的物理序列号[05-20]
Now you are ready to work with..[05-20]
使用C#实现阿拉伯数字到大写中文..[05-20]
TAPI基本函数 Only Use In TAPI ..[05-20]
C#(IsNumeric) 字符串转换为数字..[05-20]
Convert a string to an enum. (..[05-20]