当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块未执行?任何人都可以帮助我吗?
我已经构建了一个带有"登录谷歌"功能的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的回复.是否还有其他代码要求我使用此类方法?有谁能够帮我?