字符串处理
来源:百度文库 编辑:神马文学网 时间:2024/04/27 21:21:10
str.padleft(n,'*')重复输出
string str = "中国加油!";
str.Dayofweek()为星期几
str.tostring('yyyy年mm月dd日')
Response.Write(str.IndexOf("中国").ToString());//取相同字符的索引
Response.Write(str.Insert(2,"河南"));//插入
Response.Write(str.Remove(0,2));//移除
Response.Write(str.Replace("中国", "河南"));//替换
Response.Write(str.Substring(0,2));//可以用来截取身份证号获取生日
Response.Write(str.Trim());//去除两端空格
日期处理:
DateTime Mydate = new DateTime(2010,4,24);
DateTime Date1 = Mydate.AddHours(-36.3669);
DateTime Date2 = Date1.AddMonths(23);
Response.Write(Date1.ToString()+"
"+Date2.ToString());DateTime time1 = new DateTime(2010,4,24,16,48,46);
Response.Write(time1.ToString("d"));//为短日期形式只显示日期不显示时间
Response.Write(time1.ToString("dddd HH:mm:ss"));//输出星期,时间
Response.Write(time1.ToString("yy年MM月dd日"));//输出日期
数据类型处理:
byte a = 15;//单字节变量
short b = a;//微精度变量
int c = b;//整型
long d = c;//长整型
float e = d;//浮点数
double q = e;//双精度
把字符串转换为数组:
string Mydata = "hello world";
char[] data = Mydata.ToCharArray();
Response.Write(data[0]); string Mydata = "hello\\world";
string [] data = Mydata.Split('\\');//用截取字符串的方式
Response.Write(data[0].ToString());
string str = "中国加油!";
str.Dayofweek()为星期几
str.tostring('yyyy年mm月dd日')
Response.Write(str.IndexOf("中国").ToString());//取相同字符的索引
Response.Write(str.Insert(2,"河南"));//插入
Response.Write(str.Remove(0,2));//移除
Response.Write(str.Replace("中国", "河南"));//替换
Response.Write(str.Substring(0,2));//可以用来截取身份证号获取生日
Response.Write(str.Trim());//去除两端空格
日期处理:
DateTime Mydate = new DateTime(2010,4,24);
DateTime Date1 = Mydate.AddHours(-36.3669);
DateTime Date2 = Date1.AddMonths(23);
Response.Write(Date1.ToString()+"
"+Date2.ToString());DateTime time1 = new DateTime(2010,4,24,16,48,46);
Response.Write(time1.ToString("d"));//为短日期形式只显示日期不显示时间
Response.Write(time1.ToString("dddd HH:mm:ss"));//输出星期,时间
Response.Write(time1.ToString("yy年MM月dd日"));//输出日期
数据类型处理:
byte a = 15;//单字节变量
short b = a;//微精度变量
int c = b;//整型
long d = c;//长整型
float e = d;//浮点数
double q = e;//双精度
把字符串转换为数组:
string Mydata = "hello world";
char[] data = Mydata.ToCharArray();
Response.Write(data[0]); string Mydata = "hello\\world";
string [] data = Mydata.Split('\\');//用截取字符串的方式
Response.Write(data[0].ToString());
字符串处理
数据库中的字符串单引号处理
批处理中的字符串处理详解
SQL字符串处理函数大全
SQL Server字符串处理函数大全(转)_Delphi人生
VB - 自编字符串段值处理函数
处理PHP字符串的10个简单方法
化解字符串不能超过8000的方法及交叉表的处理
化解字符串不能超过8000的方法及交叉表的处理
字符串操作
字符串操作
字符串分割
字符串hash算法比较|字符串,hash,算法
用 javascript 操作字符串
字符串函数大全
KMP字符串模式匹配
用 JavaScript 操作字符串
python字符串操作
Delphi字符串函数大全
VC中字符串换行
VB.NET字符串函数
Delphi字符串函数大全
Delphi字符串函数
Sybase字符串函数