2013-02-25 104 views
-6

我對以下代碼感到困惑,它看起來像在這裏被禁用了?這個C#代碼如何工作(在aspx.cs類中)

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 
+6

Basicaly它將'null'所有參數 – Zbigniew 2013-02-25 16:07:21

+0

可能的複製:http://stackoverflow.com/questions/1419252/c-assign-same-value-to-multiple-variables-in-single-statement – 2013-02-25 16:09:00

+0

@walkhard - 行了! – Coffee 2013-02-25 16:09:03

回答

1

在C#賦值操作 「=」 上面的代碼exacutes分配的值,所以返回如下:

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

authority = null; 
password = authority; 
userName = password; 
+0

很酷,非常感謝 – Coffee 2013-02-25 16:10:30

相關問題