C#/ Xamarin bug?布尔

时间:2015-12-12 17:44:46

标签: c# xamarin

这很奇怪。我有这个C#代码:

WebViewClient webViewClient = new WebViewClient() {
    @TargetApi(VERSION_CODES.LOLLIPOP)
    @Override
    public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
        WebResourceResponse response = null;
        if ("GET".equals(request.getMethod())) {
            try {
                response = getWebResponse(view.getContext().getApplicationContext(), request.getUrl().toString());
            } catch (Exception e) {
                Log.e(TAG, "Error while overriding getting web response", e);
            }
        }
        return response;
    }

    @SuppressWarnings("deprecation")
    @Override
    public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
        WebResourceResponse response = null;
        try {
            response = getWebResponse(view.getContext().getApplicationContext(), url);
        } catch (Exception e) {
            Log.e(TAG, "Error while overriding getting web response", e);
        }
        return response;
    }

    WebResourceResponse getWebResponse(Context context, String url) {
        // YOUR IMPLEMENTATION that will save resource located at passed url
    }
}
webView.setWebViewClient(webViewClient);

当我使用Xamarin调试器检查它时,它告诉我bool value = (((Literal)expr.left).value == ((Literal)expr.right).value); value,但false(((Literal)expr.left).value == ((Literal)expr.right).value)。这是为什么?我很困惑......

1 个答案:

答案 0 :(得分:4)

找到它。 >(matches go-to-plan-manager) Matches for Pattern 1 f-4843 Activations None ((Literal)expr.left).value,这意味着除非右边和左边的相同的布尔,否则它总是会返回false。

将它们都投射到bool会比较它们的值。

object