小编yif*_*fei的帖子

java:尝试finally块执行

return;try块中存在try-finally执行时,我感到困惑.根据我的理解,finally块将始终执行,即在返回调用方法之前.在考虑以下简单代码时:

public class TryCatchTest {
    public static void main(String[] args){
        System.out.println(test());
    }
    static int test(){
        int x = 1;
        try{
            return x;
        }
        finally{
            x = x + 1;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

打印的结果实际上是1.这是否表示finally块未执行?任何人都可以帮助我吗?

java finally try-catch

31
推荐指数
2
解决办法
2624
查看次数

如何使用RestSharp进行Google身份验证?

我已经构建了一个带有"登录谷歌"功能的Windows Phone 7应用程序.Google库与Windows Phone运行时不兼容,因此我选择了RestSharp.

该应用已成功从Google收到验证码,下一步是交换代码以获取访问令牌和刷新令牌.在这里我遇到了一些问题.

var request = new RestRequest(this.TokenEndPoint, Method.POST);
request.AddParameter("code", code);
request.AddParameter("client_id", this.ClientId);
request.AddParameter("client_secret", this.Secret);
request.AddParameter("redirect_uri", "http://localhost");
request.AddParameter("grant_type", "authorization_code");
client.ExecuteAsync<???>(request, (response) =>
            {
                var passIn = response;
            }); // how to use this method?
Run Code Online (Sandbox Code Playgroud)

我不确定如何使用该client.ExecuteAsync<T>方法(或其他任何有用的方法)来获取Google的回复.是否还有其他代码要求我使用此类方法?有谁能够帮我?

.net c# windows-phone-7 restsharp

5
推荐指数
1
解决办法
1090
查看次数

标签 统计

.net ×1

c# ×1

finally ×1

java ×1

restsharp ×1

try-catch ×1

windows-phone-7 ×1