小编Moh*_*bas的帖子

是否可以在条件下使用Task <bool>?

在Windows Phone 8中我有方法public async Task<bool> authentication().函数的返回类型是bool但当我尝试在if条件错误中使用其返回值时表示无法转换Task<bool>bool.

public async Task<bool> authentication()
{
    var pairs = new List<KeyValuePair<string, string>>
    {
        new KeyValuePair<string, string> ("user", _username),
        new KeyValuePair<string, string> ("password", _password)
    };

    var serverData = serverConnection.connect("login.php", pairs);

    RootObject json = JsonConvert.DeserializeObject<RootObject>(await serverData);

    if (json.logined != "false")
    {
        _firsname = json.data.firsname;
        _lastname = json.data.lastname;
        _id = json.data.id;
        _phone = json.data.phone;
        _ProfilePic = json.data.profilePic;
        _thumbnail = json.data.thumbnail;
        _email = json.data.email;
        return true;
    }
    else
        return …
Run Code Online (Sandbox Code Playgroud)

c# task-parallel-library async-await c#-5.0 windows-phone-8

18
推荐指数
1
解决办法
3万
查看次数

如何阻止HttpUtility.UrlEncode()从+更改为空格?

我正在使用HttpUtility.UrlEncode()字符串令牌,原始令牌是t+Bj/YpH6zE=HttpUtility.UrlDecode()它变为t Bj/YpH6zE=打破算法时.是一种停止在c#中将+更改为空格的方法.

我目前正在使用replace方法来实现这一点 var token_decrypt = HttpUtility.UrlDecode(token).Replace(" ", "+");

public HttpResponseMessage RegisterUser(User user, string token)
        {
            int accID;

            if(string.IsNullOrWhiteSpace(token))
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
            else
            {
                try
                {
                     // token now = t Bj/YpH6zE= which will fail 
                     var token_decrypt = HttpUtility.UrlDecode(token);
                      token now = t Bj/YpH6zE= still the same 
                     accID = int.Parse(Crypto.Decrypt(token_decrypt, passPhrase));
                }
                catch
                {
                    return Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid account ");
                }
Run Code Online (Sandbox Code Playgroud)

她编码令牌

  string encoded_token = HttpUtility.UrlEncode(token);

            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
            SmtpClient …
Run Code Online (Sandbox Code Playgroud)

c# asp.net c#-4.0

5
推荐指数
2
解决办法
3136
查看次数

在二元和三元(或更高程度)关系之间

二元关系与三元或更高程度关系之间有什么区别?

database uml

4
推荐指数
1
解决办法
2万
查看次数