Let's go

C#常用操作

一丶C#删除最后一个字符

例:字符串 string str="1,2,3,4,5,,6,7,8,9,"

去掉最后一个逗号 ",";

常用的方法:

1.SubString()方法

str=str.SubString(0,str.Length - 1);

2.Remove()方法

str=str.Remove(str.Length-1,1);

3.TrimEnd()方法

str=str.TrimEnd(',');

二丶后台获取值

string user_IP = System.Web.HttpContext.Current.Request.ServerVariables["remote_addr"];
string user_Url = System.Web.HttpContext.Current.Request.ServerVariables["Url"];
string user_fwIP = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_NAME"];
string aa = System.Web.HttpContext.Current.Request.UserHostAddress;
string Local_Addr = System.Web.HttpContext.Current.Request.ServerVariables["Local_Addr"];
string url1 = System.Web.HttpContext.Current.Request.UrlReferrer.ToString();//获取上一个页面的url
string url2 = System.Web.HttpContext.Current.Request.Url.ToString();

...

posted @ 2018-12-14 11:53  chenze  阅读(154)  评论(0编辑  收藏  举报
有事您Q我