在用httpWebRequest模拟请求的时候有时因为服务器等方面做了请求的限制, 在请求会出现基础连接已经关闭: 接收时发生意外错误的错误 一般原因是因为服务器不允许与 Internet 资源建立持久性连接连接和http的版本造成 做如下简单修改httpWebRequest即可解决 1 2 request.KeepAlive = false; //设置不建立持久性连接连接 request.ProtocolVersion = HttpVersion.Version10; //http的版本有2个,一个是1.0,一个是1.1 具体更具实际情况测试替换 from:https://www.cnblogs.com/yunspider/p/5020103.html
View Details找了好久,最后在国外的论坛找到了解决办法,直接贴代码吧。 方法一:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
public static class MemberInfoGetting { public static string GetMemberName<T>(Expression<Func<T>> memberExpression) { MemberExpression expressionBody = (MemberExpression)memberExpression.Body; return expressionBody.Member.Name; } } string TableName = "123"; string nameOfTestVariable = MemberInfoGetting.GetMemberName(() => TableName); //最后得到 nameOfTestVariable = "TableName" |
方法二:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
static void Main(string[] args) { GetName(new { var1 }); GetName2(() => var1); GetName3(() => var1); } static string GetName<T>(T item) where T : class { return typeof(T).GetProperties()[0].Name; } static string GetName2<T>(Expression<Func<T>> expr) { return ((MemberExpression)expr.Body).Member.Name; } static string GetName3<T>(Func<T> expr) { return expr.Target.GetType().Module.ResolveField(BitConverter.ToInt32(expr.Method.GetMethodBody().GetILAsByteArray(), 2)).Name; } |
from:https://www.cnblogs.com/huangcong/p/3459307.html
View Details1.round() 函数是四舍五入用,第一个参数是我们要被操作的数据,第二个参数是设置我们四舍五入之后小数点后显示几位。 2.numeric 函数的2个参数,第一个表示数据长度,第二个参数表示小数点后位数。 例如: select cast(round(12.5,2) as numeric(5,2)) 结果:12.50 select cast(round(12.555,2) as numeric(5,2)) 结果:12.56 select cast(round(122.5255,2) as numeric(5,2)) 结果:122.53 select cast(round(1222.5255,2) as numeric(5,2)) 结果:报错了! 原因是:1222.5255,整数位是4,小数位是2,加起来4+2=6,超出了numeric设置的5位,所以为了保险,可以增减numeric的参数,例如numeric(20,2)。 此文系转载后作一调整,转载自:http://blog.csdn.net/caoyuanlang_11/article/details/5410833
View Details