以下调用返回值0:
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
clientRuntime.MessageInspectors.Add(new BizTalkRESTTransmitHandler());
#can IErrorHandler be added to client?
}
// Apparently ApplyDispatchBehavior only applies if you are the server, not the client
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
BizTalkRESTTransmitErrorHandler handler = new BizTalkRESTTransmitErrorHandler();
endpointDispatcher.ChannelDispatcher.ErrorHandlers.Add(handler);
}
我在Google Chrome版本64.0.3282.119
中尝试过但是,这种行为定义明确吗?我不确定它在其他浏览器中的行为是否相同。
答案 0 :(得分:2)
对于字符串到数字的转换,下一节中添加了相关信息:https://www.ecma-international.org/ecma-262/8.0/index.html#sec-tonumber-applied-to-the-string-type
答案 1 :(得分:0)
是的,这是所有浏览器的预期行为。
传递给Number构造函数的任何非可执行值都将返回0.
var num1 = Number();
var num2 = Number("");
var num3 = Number(false);
var num4 = Number(null);
// here num1, num2, num3 and num4 will be 0 as undefined, empty string, false and null are non-executable values.
如果将可执行的非数字值传递给Number的构造函数,它将返回NaN
var num5 = Number("abc");
var num6 = Number({});
var num7 = Number([]);
// num5, num6 and num7 will be NaN as non-empty string, any object and any array are executable but Not a number values.
答案 2 :(得分:-1)
当没有提供参数时,Number()将始终返回0并且如果参数是非法的,那么Number()将返回NaN