system.datetime currenttime=new system.datetime();
currenttime=system.datetime.now;
int 年=currenttime.year;
int 月=currenttime.month;
int 日=currenttime.day;
int 時=currenttime.hour;
int 分=currenttime.minute;
int 秒=currenttime.second;
int 毫秒=currenttime.millisecond;
(變量可用中文)
string stry=currenttime.tostring("f"); //不顯示秒
string strym=currenttime.tostring("y");
string strmd=currenttime.tostring("m");
string strymd=currenttime.tostring("d");
string strt=currenttime.tostring("t");
int len = str.length ; //len是自定義變量, str是求測的字串的變量名
system.text.stringbuilder sb = new system.text.stringbuilder("");
sb.append("中華");
sb.append("人民");
sb.append("共和國");
string user_ip=request.servervariables["remote_addr"].tostring();
if(request.servervariables["http_via"]!=null){
string user_ip=request.servervariables["http_x_forwarded_for"].tostring();
}else{
string user_ip=request.servervariables["remote_addr"].tostring();
}
session["變量"];
session["username"]="小布什";
object objname=session["username"];
string strname=objname.tostring();
session.removeall();
string str=request.querystring["變量"];
response.write("字串");
response.write(變量);
response.redirect("url地址");
char.iswhitespce(字串變量,位數)——邏輯型;
string str="中國 人民";
response.write(char.iswhitespace(str,2)); //結果為:true, 第一個字符是0位,2是第三個字符。
char.ispunctuation('字符') --邏輯型
response.write(char.ispunctuation('a')); //返回:false
response.write((int)'中'); //結果為中字的代碼:20013
response.write((char)22269); //返回“國”字。
string str="中國";
str=str.replace("國","央"); //將國字換為央字
response.write(str); //輸出結果為“中央”
string str="這是<script>腳本";
str=str.replace("<","<font><</font>"); //將左尖括號替換為<font> 與 < 與 </font> (或換為<,但估計經xml存諸后,再提出仍會還原)
response.write(str); //顯示為:“這是<script>腳本”
string strsubmit=label1.text; //label1是你讓用戶提交數據的控件id。
strsubmit=strsubmit.replace("<","<font><</font>");
string str1; str2
//語法: str1.endswith(str2); __檢測字串str1是否以字串str2結尾,返回布爾值.如:
if(str1.endswith(str2)){ response.write("字串str1是以"+str2+"結束的"); }
//語法:str1.equals(str2); __檢測字串str1是否與字串str2相等,返回布爾值,用法同上.
//語法 equals(str1,str2); __檢測字串str1是否與字串str2相等,返回布爾值,用法同上.
str1.indexof("字"); //查找“字”在str1中的索引值(位置)
str1.indexof("字串");//查找“字串”的第一個字符在str1中的索引值(位置)
str1.indexof("字串",3,2);//從str1第4個字符起,查找2個字符,查找“字串”的第一個字符在str1中的索引值(位置)
str1.insert(1,"字");在str1的第二個字符處插入“字”,如果str1="中國",插入后為“中字國”;
<%
string str1="中國人";
str1=str1.padleft(10,'1'); //無第二參數為加空格
response.write(str1); //結果為“1111111中國人” , 字串長為10
%>
har[] chararray = "abcde".tochararray();
array.reverse(chararray);
console.writeline(new string(chararray));
string str="abceedddd";
response.write(char.isupper(str,3));
最大的網站源碼資源下載站,
新聞熱點
疑難解答