要引用System
using System;
給一個字符串賦值
1.string a;
a="12345";
string a="123456";
2.轉換到大寫
a.ToUpper();
3轉換爲小寫
a.ToLower();
3取某字符串中間的從某處到某處的子字符串(與VB的不同,是從0開始的)
a.Substring(0, 2);從第一個開始取兩個字符
4取字符串裏面的某個字符的位置,如果沒有返回0;
int b = a.IndexOf('1');
5.靜態方法
ForMat,格式化字符串
lbl.Text = string.Format("{0}:{1}({2}:{3})", DataBinder.Eval(e.Row.DataItem, "HGoals"),
DataBinder.Eval(e.Row.DataItem, "AGoals"), DataBinder.Eval(e.Row.DataItem, "HGoals_half"),
DataBinder.Eval(e.Row.DataItem, "AGoals_half"));
6.Split的使用,返回一個字符數組
string a = "2|3|4|5";
string[] a_arr = a.Split('|');
7取得字符串數組的長度,從0開始
a.GetLength(0);
8取得一個字符串的長度
string a = "1234";
a.Length;
9.字符串數組的定義和賦值
string[] str_Pass_canshus = new string[3];
string[] str_Pass_canshuvalues = new string[3];
str_Pass_canshus[0] = "@MatchID";
str_Pass_canshus[1] = "@Act";
str_Pass_canshus[2] = "@result";