【问题标题】:How does this C# code work (in aspx.cs class) [closed]此 C# 代码如何工作(在 aspx.cs 类中)[关闭]
【发布时间】:2013-02-25 16:06:32
【问题描述】:

我对下面的代码感到困惑,看起来它在这里被禁用了?

    public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority) {
        authCookie = null;
        userName = password = authority = null;
        return false;
    }

不应该是这样的吗?

userName =  myName
password =  12345
authority = someAuthority

【问题讨论】:

  • 基本上它会null所有参数
  • @walkhard - 好的!
  • -1,因为“不应该是这样吗”没有上下文是无法回答的。
  • 不太明白你的问题。正如@walkhard 所说,您拥有的方法只是返回所有输出参数并运行并导致错误。在我看来,有人应该实现的存根代码。另外,不确定您所说的“看起来它在此处已被禁用”是什么意思。

标签: c# asp.net


【解决方案1】:

C#赋值操作中“=”返回赋值,所以上面的代码执行如下:

userName = (password = (authority = null));

authority = null;
password = authority;
userName = password;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-12
    • 2017-05-12
    • 2011-11-24
    • 2016-04-08
    相关资源
    最近更新 更多