代码积累

(1)String cusId = Request["cusId"]??"0";

(2)

protected void Page_Load(object sender, EventArgs e)
{
try
{
string funcName =Request["funcName"];
if (!string.IsNullOrEmpty(funcName))
{
Type type = this.GetType();
string methodName = "Exec" + funcName;
MethodInfo method = type.GetMethod(methodName);
method.Invoke(this, null);
}
}
catch
{
Response.Write("funcName不存在!");
}
}
public void ExecLinkMan()
{
Response.Write("LinkMan");
}
public void ExecCustomer()
{
Response.Write("ExecCustomer");
}

(3)设置默认值

[System.ComponentModel.DefaultValue(true)]
public Boolean IsRightOpt { get; set; }//是否需要验证权限操作

(4)读取一网页  并对其数据进行操作

public static string[] GetPoint(string addr)
{
string[] arrag = null;
string path = "http://maps.googleapis.com/maps/geo?output=csv&q=" + addr;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(path);
request.Method = "get";
HttpWebResponse resp = (HttpWebResponse)request.GetResponse();
request.Timeout = 30 * 1000;
if (resp.StatusCode == HttpStatusCode.OK)
{
StreamReader stream = new StreamReader(resp.GetResponseStream(), Encoding.UTF8);
//格式:200,4,31.2219590,121.5447210
string body = stream.ReadToEnd();
arrag = body.Split(',');
resp.Close();
}
}
catch
{
}
return arrag;
}

5:定义属性的简写

public String ClientZipcode
{
get;
set;
}

原文地址:https://www.cnblogs.com/ctriphire/p/2914322.html