2013-02-09 44 views
6

的輸出的格式:奇怪的行爲與非公有制識別聯合

type Test = 
    | First 
    | Second 
    | Third 

let test = First 

printf "test=%A" test 

test=First 

不如預期,但如果我宣佈類型internal

type internal Test = 
    | First 
    | Second 
    | Third 

let internal test = First 

printf "test=%A" test 

輸出變爲:

test=FSI_0019+Test 

這是故意的嗎?爲什麼?還是一個錯誤?

我使用Visual Studio 2010中使用F#2.0

回答

11

要打印非公共成員使用 '+' 標誌。它在MSDN中缺少的事實看起來像doc問題:

printf "test=%+A" test 
+0

謝謝!很高興,這不是我俯瞰明顯的東西 – MiMo 2013-02-09 22:41:10

+0

僅供參考,我們現在已經在MSDN上更新它:http://msdn.microsoft.com/en-us/library/ee370560.aspx – latkin 2013-02-27 23:19:19