Compare   比较字符串的内容,考虑文化背景(场所),确定某些字符是否相等
 
CompareOrdinal  与Compare一样,但不考虑文化背景
 
Format   格式化包含各种值的字符串和如何格式化每个值的说明符
 
IndexOf   定位字符串中第一次出现某个给定子字符串或字符的位置
 
IndexOfAny  定位字符串中第一次出现某个字符或一组字符的位置
 
LastIndexOf  与IndexOf一样,但定位最后一次出现的位置
 
LastIndexOfAny  与IndexOfAny,但定位最后一次出现的位置
 
PadLeft   在字符串的开头,通过添加指定的重复字符填充字符串
 
PadRight  在字符串的结尾,通过添加指定的重复字符填充字符串
 
Replace   用另一个字符或子字符串替换字符串中给定的字符或子字符串

 

C#字符串函数1、DateTime 数字型 
C#字符串函数System.DateTime currentTime
=new System.DateTime(); 
C#字符串函数
1.1 取当前年月日时分秒 
C#字符串函数currentTime
=System.DateTime.Now; 
C#字符串函数
1.2 取当前年 
C#字符串函数
int 年=currentTime.Year; 
C#字符串函数
1.3 取当前月 
C#字符串函数
int 月=currentTime.Month; 
C#字符串函数
1.4 取当前日 
C#字符串函数
int 日=currentTime.Day; 
C#字符串函数
1.5 取当前时 
C#字符串函数
int 时=currentTime.Hour; 
C#字符串函数
1.6 取当前分 
C#字符串函数
int 分=currentTime.Minute; 
C#字符串函数
1.7 取当前秒 
C#字符串函数
int 秒=currentTime.Second; 
C#字符串函数
1.8 取当前毫秒 
C#字符串函数
int 毫秒=currentTime.Millisecond; 
C#字符串函数(变量可用中文) 
C#字符串函数
2、Int32.Parse(变量) Int32.Parse("常量"
C#字符串函数字符型转换 转为32位数字型 
C#字符串函数
C#字符串函数
3、 变量.ToString() 
C#字符串函数字符型转换 转为字符串 
C#字符串函数
12345.ToString("n"); //生成 12,345.00 
C#字符串函数
12345.ToString("C"); //生成 ¥12,345.00 
C#字符串函数
12345.ToString("e"); //生成 1.234500e+004 
C#字符串函数
12345.ToString("f4"); //生成 12345.0000 
C#字符串函数
12345.ToString("x"); //生成 3039 (16进制) 
C#字符串函数
12345.ToString("p"); //生成 1,234,500.00% 
C#字符串函数

C#字符串函数
C#字符串函数
4、变量.Length 数字型 
C#字符串函数取字串长度: 
C#字符串函数如: 
string str="中国"
C#字符串函数
int Len = str.Length ; //Len是自定义变量, str是求测的字串的变量名 
C#字符串函数

C#字符串函数
5、System.Text.Encoding.Default.GetBytes(变量) 
C#字符串函数字码转换 转为比特码 
C#字符串函数如:
byte[] bytStr = System.Text.Encoding.Default.GetBytes(str); 
C#字符串函数然后可得到比特长度: 
C#字符串函数len 
= bytStr.Length; 
C#字符串函数
C#字符串函数
6、System.Text.StringBuilder(""
C#字符串函数字符串相加,(
+号是不是也一样?) 
C#字符串函数如:System.Text.StringBuilder sb 
= new System.Text.StringBuilder(""); 
C#字符串函数sb.Append(
"中华"); 
C#字符串函数sb.Append(
"人民"); 
C#字符串函数sb.Append(
"共和国"); 
C#字符串函数
C#字符串函数
7、变量.Substring(参数1,参数2); 
C#字符串函数截取字串的一部分,参数1为左起始位数,参数2为截取几位。 
C#字符串函数如:
string s1 = str.Substring(0,2); 
C#字符串函数
C#字符串函数
8、String user_IP=Request.ServerVariables["REMOTE_ADDR"].ToString(); 
C#字符串函数取远程用户IP地址 
C#字符串函数
C#字符串函数
9、穿过代理服务器取远程用户真实IP地址: 
 

相关文章: